WordPress特色帖子并分享了这个问题

时间:2011-10-14 11:39:46

标签: wordpress sharethis

我在使用这个特色后期功能时遇到了一些麻烦。我遇到的问题是查询时('showposts = 1');设置特色帖子没有被提取。但是当我把查询(''); sharethis插件不起作用。任何人都可以帮助我解决我可能做错的事情。

<div id="block_feature">
    <div id="featured_post" class="post">
        <div class="post_inner">

            <?php
            $featured = new WP_Query();
            $featured->query('showposts=1');
            while($featured->have_posts()) : $featured->the_post();

            //$wp_query->in_the_loop = true; // This line is added so that the_tags('') will work outside the regular loop.
            $featured_ID = $post->ID; // We'll store this here so that we know to skip this post in the main loop
            ?>

                <?php if(get_post_meta($post -> ID, 'feature', true)) { ?>


                    <?php if (get_post_meta($post->ID, 'large_preview', true)) { ?>
                        <div class="post_image">
                        <img src="<?php echo get_post_meta($post->ID,'large_preview',true);?>" width=150px; height=150px alt="Featured Post"/>
                        </div>
                    <?php } ?>

                        <div class="excerpt">
                        <h2><a href="<?php the_permalink();?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
                        <small>on <?php the_time('M d'); ?> in <?php the_category(',');?> tagged <?php the_tags(''); ?></small>
                        <?php the_excerpt();?>
                        </div>
                        <a href="<?php the_permalink(); ?>" class="readMore">Read More</a>  


                <?php } ?>
            <?php endwhile; ?> 
        </div>                        
    </div>                   
</div> 

1 个答案:

答案 0 :(得分:1)

自版本2.1以来,

showposts已被弃用,因此最好使用posts_per_page。不确定它是否会有所不同,但你也可以用$featured = new WP_Query('showposts=1');

替换前两行PHP

至于造成问题的原因我不确定,你的查询对我来说很好,你没有提到以什么方式分享这个失败。我不熟悉Share This插件,但大多数此类插件使用附加到the_content过滤器的过滤器功能将其内容添加到帖子中。也就是说,可能只是您使用的是the_excerpt()而不是the_content()