【问题标题】:Wordpress plugin Manual Related PostsWordpress 插件手册 相关文章
【发布时间】:2015-02-02 14:38:05
【问题描述】:

我刚刚安装了 Wordpress 插件:手动相关帖子 (https://wordpress.org/plugins/baw-manual-related-posts/)

安装后,我尝试将相关帖子手动添加到页面。
但是我只能选择帖子或页面......关于插件应该也可以使用媒体功能但它不会显示。

我已降级到 Wordpress 3.9.2,这是此插件所需的版本(不支持较新的 wordpress 版本)

希望有人能帮我解决这个问题。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    尝试使用此代码在您的博客中手动添加相关帖子

    <div class="relatedposts">
        <h3>Related posts</h3>
        <?php
            $orig_post = $post;
            global $post;
            $tags = wp_get_post_tags($post->ID);
     
            if ($tags) {
                $tag_ids = array();
            foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
                $args=array(
                    'tag__in' => $tag_ids,
                    'post__not_in' => array($post->ID),
                    'posts_per_page'=>4, // Number of related posts to display.
                    'caller_get_posts'=>1
                );
     
            $my_query = new wp_query( $args );
     
            while( $my_query->have_posts() ) {
                $my_query->the_post();
            ?>
     
            <div class="relatedthumb">
                <a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
                <?php the_title(); ?>
                </a>
            </div>
     
            <?php }
            }
            $post = $orig_post;
            wp_reset_query();
            ?>
        </div>

    【讨论】:

      猜你喜欢
      • 2010-11-01
      • 2018-07-25
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-04
      相关资源
      最近更新 更多