SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question have_posts() have_page()?

    I'm working on a school project and am trying to alter the code so that instead of new posts showing up in a slide image in the header of the theme, it will display pages. Is there a easy way to do this. Is have_page() a way to call pages instead of posts? The code looks like this:

    Code:
    <div id="slidearea">
    <?php 
    	$gldcat =get_option('evandr_gldcat'); 
    	$gldct = get_option('evandr_gldct');
    ?>
    <div id="gallerycover">
    <div class="mygallery">
    <ul>
    <?php 
    	$my_query = new WP_Query('category_name='.$gldcat.'&showposts='.$gldct.'');
    	while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
    ?>
        <li>
    		<a href="<?php the_permalink() ?>">	<?php evandr_slide_image(); ?> </a>
    	</li>
    	<?php endwhile; ?>
    </ul>
    <div class="clear"></div>  
    </div>
    </div>
       <a href="#" class="prevb"><img src="<?php bloginfo('template_directory'); ?>/images/prev.png" alt="Previous" /></a>
       <a href="#" class="nextb"><img src="<?php bloginfo('template_directory'); ?>/images/next.png" alt="Next" /></a>   
      
    <div id="textcover">
    <div class="mytext">
    
    <ul>
    <?php 
    $my_query = new WP_Query('category_name='.$gldcat.'&showposts='.$gldct.'');
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
    ?>
        <li>
    			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    			<p>  <?php the_content_rss('', TRUE, '', 50); ?> </p>
                        
    	</li>
    	<?php endwhile; ?>
    </ul>
    <div class="clear"></div>  
    </div>
    </div>
    </div>
    I want it to display pages, not posts and link to the pages. The theme I'm using is called Evander (Evander | web2feel.com - Free wordpress themes - Tutorials - Tips and tricks)

    What I have done so far is live at JA-CF

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    You need to modify this:
    Code:
    new WP_Query('category_name='.$gldcat.'&showposts='.$gldct.'');
    To get pages. You can just add something like "&post_type=page".

    In Wordpress, everything is either a post (post, pages, menu items, etc) or a taxonomy (tags, categories, etc). So, even if you're using "have_posts", it still may be a page... it's all about what is in the query.

  3. #3
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi i have the same problem. I want to feature pages images in the slide instead of post in the home page. I tryied to do what you syggest but the only thing hthat change is that the slider doesn't show anything more.
    Any suggestion?
    What i have to change in this code?

    $my_query = new WP_Query('category_name='.$gldcat.'&showposts='.$gldct.'');
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;

  4. #4
    SitePoint Member mhkdeveloper's Avatar
    Join Date
    Feb 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $query->have_pages ?

    I want to check and get all pages like post

    $query->have_posts()
    $query->the_post()


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •