【问题标题】:join table with query posts使用查询帖子连接表
【发布时间】:2013-02-18 07:35:18
【问题描述】:

我有一张桌子:

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

我有一个书签系统,当用户按下“书签”时,它应该插入以下信息:

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

我想要做的是编写一个查询来显示带有上表的书签帖子。我想写一个 JOIN 但我不知道如何用 Wordpress 的语法来做。

这是我尝试过的:

<?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;
?>

【问题讨论】:

    标签: php mysql wordpress join


    【解决方案1】:

    这里有一些选择

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

    您可以尝试过滤 add_filter('posts_join', 'your_function');

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

    【讨论】:

    猜你喜欢
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多