template-sitemap.php – want to output custom post type

Support Forums for LiveMesh Themes & Plugins Forums Invent Theme Support template-sitemap.php – want to output custom post type

Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32063
    palmtree
    Participant

    Hi there,

    I would like to output staff list in the sitemap page.

    <?php wp_list_pages(array(
      'post_type' => 'staff',
      'title_li' => ''
     ));
    ?>

    This one did not work…
    Could you tell me the appropriate code?

    Thanks

    #32079
    Raghavendra
    Moderator

    The correct should be (if you have not figured this out already) –

    <h2 id="staff-list"><?php echo esc_html__('Our Staff', 'invent'); ?></h2>
    
                            <ul class="list1">
    
                                <?php
    
                                $loop = new WP_Query(array('post_type' => 'staff', 'posts_per_page' => ' - 1'));
    
                                while ($loop->have_posts()) : $loop->the_post();
    
                                    ?>
    
                                    <li>
    
                                        <a href="<?php echo get_permalink(); ?>">
    
                                            <?php echo get_the_title(); ?>
    
                                        </a>
    
                                    </li>
    
                                <?php endwhile; ?>
    
                                <?php wp_reset_postdata(); ?>
    
                            </ul>
    #32084
    palmtree
    Participant

    Hello Raghavendra,

    Thanks for your reply with the code. I appreciate it a lot but the code is only outputting 1 staff….
    I have 13 staffs.

    It would be great if you could help me to resolve this…

    #32085
    Raghavendra
    Moderator

    Sure. Pls change the line

    $loop = new WP_Query(array('post_type' => 'staff', 'posts_per_page' => '-1'));

    to

    $loop = new WP_Query(array('post_type' => 'staff', 'posts_per_page' => -1));

    #32086
    palmtree
    Participant

    AMAZING!!!!!!!!!!

    Now it output 13 staffs.

    Thank you so much!!:)))))

    #32087
    Raghavendra
    Moderator

    You are welcome.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Invent Theme Support’ is closed to new topics and replies.