The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to display an index-like page for "Custom Post Types" (3 posts)

  1. FeralReason
    Posted 2 years ago #

    I have a custom post type called "articles" where I want to be able to click on a menu link and display a number of article summaries (title, author, date, excerpt) on one page -- in the same way an index.php page would display ordinary posts.

    Currently, I have an "Articles" blank page so these summaries are being displayed by using a template: archive-articles.php (as the Codex suggests) but this displays an "Archives" heading at the top. I need to find a way to get rid of the "Archives" heading when the intention is just displaying the "Articles" page, but still allow this heading when I'm clicking a link to actually show an archive.

    There has to be a way to do this... any ideas?

  2. Jose Castaneda
    Posted 2 years ago #

    A lot of it does deal with the theme, of course. What does the archive-articles.php look like? If more than 10 lines please use a gist or pastebin.com to post the code. :)

  3. FeralReason
    Posted 2 years ago #

    archive-articles.php is a copy of Twentythirteen's archive.php. The relevant code is:

    <h1 class="archive-title"><?php
     if ( is_day() ) :
       printf( __( 'Daily Archives: %s', 'twentythirteen' ), get_the_date() );
     elseif ( is_month() ) :
       printf( __( 'Monthly Archives: %s', 'twentythirteen' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'twentythirteen' ) ) );
     elseif ( is_year() ) :
       printf( __( 'Yearly Archives: %s', 'twentythirteen' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentythirteen' ) ) );
     else :
       _e( 'Archives', 'twentythirteen' );

    You can see that the content of the H1 tag is changed according to tests of is_day(), is_month(), etc. However, I know of no "if condition" I can check to determine whether or not to display 'Archives' in the H1. Functions like is_archive() or is_post_type_archive('articles') will always return TRUE. (I've tried these.)

Topic Closed

This topic has been closed to new replies.

About this Topic