需要显示帖子而不是投资组合项目

时间:2012-11-21 13:54:37

标签: php mysql wordpress

我只有一个支持在全宽度投资组合主页上显示投资组合项目的主题,这些投资组合项目不支持视频,但我可以在普通帖子中嵌入视频 我需要做的是改变家庭以显示例如类别帖子, 这是代码

<?php 

                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    $showposts = $data['home_recent_number']; 

                    $args = array(
                                    'showposts' => $showposts ,
                                    'post_type' => 'portfolioentry'
                                  );

                    $my_query = new WP_Query($args);
                    $wp_query = $my_query;

                    //query_posts("showposts=$showposts&post_type=portfolioentry&paged=$paged");
                    query_posts("showposts=$showposts&post_type=portfolioentry&paged=$paged");

                    $limit_text = 100;
                    $currentindex = '';
                    $counter = 0;
                    $count = 0;
                    $temp = '';
                    while ( have_posts() ) : the_post();
                        $do_not_duplicate = $post->ID; 
                        $full_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false);
                        $entrycategory = get_the_term_list( $post->ID, 'portfoliocategory', '', '_', '' );
                        $catstring = $entrycategory;
                        $catstring = strip_tags($catstring);
                        $catstring = str_replace('_', ', ', $catstring);
                        $categoryname = $catstring;                         
                        $entrycategory = strip_tags($entrycategory);
                        $entrycategory = str_replace(' ', '-', $entrycategory);
                        $entrycategory = str_replace('_', ' ', $entrycategory);

                        $catidlist = explode(" ", $entrycategory);
                        for($i = 0; $i < sizeof($catidlist); ++$i){
                            $catidlist[$i].=$currentindex;
                        }
                        $catlist = implode(" ", $catidlist);


                        $category = get_the_term_list( $post->ID, 'portfoliocategory', '', ', ', '' );  

                        if(isset($full_image[0]))
                            $img = get_template_directory_uri() .'/js/timthumb.php?src='.$full_image[0] .'&';
                        else
                            $img = get_template_directory_uri() .'/js/timthumb.php?src='.get_template_directory_uri() .'/images/placeholder-port.png&';

                        ?>
                            <div class="item4">



                        <a href="<?php the_permalink(); ?>">
                            <div class="overdefult">

                                <div class="viewIcon"><?php echo getPostViews(get_the_ID()); ?></div>
                                <div class="likeIcon"><?php echo GetWtiLikeCount($post->ID) ?></div>

                            </div>
                        </a>
                        <div class = "detailsoverdefault">
                            <h3><a href="<?php //the_permalink(); ?>"><?php $title = substr(the_title('','',FALSE),0,30); echo $title  ?></a></h3>
                            <a href="<?php //the_permalink(); ?>"><div class = "moreButton">+</div></a>
                        </div>
                        <div class="image">

                            <img class="newimage <?php echo $newheight ?>" src="<?php echo  $img ?>" alt="<?php the_title(); ?>">
                        </div>  

                        </div>  
                    <?php 




                    endwhile; 
                    ?>

    </div>


</div>


非常感谢。 该主题的演示位于http://key-film.com/beta/

2 个答案:

答案 0 :(得分:0)

试试这个

post_type =交

query_posts("showposts=$showposts&post_type=post&paged=$paged");

答案 1 :(得分:0)

替换

$args = array(
    'showposts' => $showposts ,
    'post_type' => 'post', //select posts
    'paged' => $paged,
);

删除query_posts(加载时间不好)

用while:

替换while循环的行
while ( $my_query->have_posts() ) : $my_query->the_post();