首页 文章

Wordpress插件手册相关文章

提问于
浏览
1

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

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

我降级到Wordpress 3.9.2这是这个插件所需的版本(不支持更新的wordpress版本)

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

1 回答

  • 0

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

    <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)); ?>
    <?php the_title(); ?> </a> </div> <?php } } $post = $orig_post; wp_reset_query(); ?> </div>

相关问题