WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display loop only on a certain page? (2 posts)

  1. MrThunder
    Member
    Posted 1 year ago #

    Hi wish to display this loop only on my latest news page. But I cannot get it work. How do I do it right?

    Thanks

    <?php is_page('latest_news'); ?>
     echo
    <?php query_posts( 'post_type=latestnews&posts_per_page=9&offset=5'); ?>
    
    <div id="recent-posts-side" style="">
    <div class="grid-box width100 grid-v">
    	<div class="module mod-dark  deepest">
    	<h3 class="module-title">Most Recent ArticleZ</h3>
    	<ul class="line">
    				 <?php $currentid = get_the_id(); ?>
    				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    				  <?php $currentid = get_the_id(); ?>
    
                            		<li>
                            			<a href="<?php the_permalink(); ?>"><?php echo get_the_title($currentid); ?></a>
                            		</li>
    	                    <?php
    	                endwhile;
    	            endif;
                wp_reset_query();
                ?>
                </ul>
       	</div>
    </div>
    </div>
    <?php } ?>
  2. MrThunder
    Member
    Posted 1 year ago #

    Its fine, I got it fixed I was using an archive so it was different.

    <?php
    if ( is_post_type_archive('musicnews') ) {
        ?>
    
    <?php query_posts( 'post_type=musicnews&posts_per_page=9&offset=5'); ?>
    <div id="recent-posts-side" style="">
    	<div class="grid-box width100 grid-v">
    		<div class="module mod-dark  deepest">
    		<h3 class="module-title"><?php post_type_archive_title(); ?></h3>
    		<ul class="line">
    					 <?php $currentid = get_the_id(); ?>
    					<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    					  <?php $currentid = get_the_id(); ?>
    
    	                        		<li>
    	                        			<a href="<?php the_permalink(); ?>"><?php echo get_the_title($currentid); ?></a>
    	                        		</li>
    		                    <?php
    		                endwhile;
    		            endif;
    	            wp_reset_query();
    	            ?>
    	            </ul>
    	   	</div>
    	</div>
    </div>
        <?php
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic