wassimo
wassimo

Reputation: 21

join table with query posts

I have a table:

userbookmark
contants fields 
1-id
2- user_id
3- post_id 

I have a bookmark system, when a user presses 'Bookmark' it should insert this information:

1-id  ( autoinc..)
2- user_id ( 1 for  example  )
3- post_id ( 1 for example )

What I want to do is to write a query to show bookmarked posts with table above. I want to write a JOIN but I don't know how to do it in Wordpress' syntax.

Here's what I have tried:

<?php
     $args = array(
                   'cat' => '1',
                   'author' => '1',
                   'post_type' => 'post',
                   'posts_per_page' => 6,
                   'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                   );

    query_posts($args);

while (have_posts()) : the_post();
 /* Do whatever you want to do for every page... */
?>
    <a href=""><?php the_title();?></a><br />


      <?php

endwhile;
?>

Upvotes: 2

Views: 5934

Answers (1)

ovi_mihai
ovi_mihai

Reputation: 91

You have some options here

http://codex.wordpress.org/Class_Reference/WP_Query

You can try filtering add_filter('posts_join', 'your_function');

http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join

Upvotes: 1

Related Questions