• Hi Im using the following code to create an a-z list of a custom post type.
    I need to add a link to the title and dispaly the Exceprt too, but am unsire on how to include this into this function.
    Could anyone help?

    Many thanks

    <?php
    
    $AZposts = get_posts(array(
        'numberposts'     => -1,
        'post_type'       => 'bha_issues',
        'orderby'         => 'title',
        'order'           => 'ASC',
        'category'    => $cat
    ));
    
    $current = "";
    $nav = "";
    $postlist = "";
    foreach($AZposts as $AZpost) {
        $firstletter = strtoupper(substr($AZpost->post_title,0,1));
        if($firstletter != $current) {
            $postlist .= "<b><a name='$firstletter'> $firstletter </a></b><br>\n";
            $nav .= "<a href='#$firstletter'> $firstletter </a> ";
            $current = $firstletter;
    
        } ?>
       <?php $postlist .= $AZpost->post_title . "<br>\n"; ?>
    <?php } ?>
    <?php
    print $nav . "<br>" . $postlist;
    ?>

  • The topic ‘A-Z index on Custom post type’ is closed to new replies.