0

I'm using the Twenty Fourteen theme and think it's stupid to show full posts in the Archives section. I want just the titles to be displayed for easier navigation. Even removing the dates would be nice. (I've already done so for individual posts but the Archives section still says May 2014.) This is minor though. The main thing I'd like to know is how to only display the title.

I've looked at the archive.php file (included below) but don't know php and have no idea what to do. The advice I've found through googling is outdated and the code samples don't match mine. Please o' gracious lords of the internet, tell me what needs to be changed so my site can suck a little less.

get_header(); ?>

    <section id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title">
                    <?php
                        if ( is_day() ) :
                            printf( __( 'Daily Archives: %s', 'twentyfourteen' ), get_the_date() );

                        elseif ( is_month() ) :
                            printf( __( 'Monthly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyfourteen' ) ) );

                        elseif ( is_year() ) :
                            printf( __( 'Yearly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentyfourteen' ) ) );

                        else :
                            _e( 'Archives', 'twentyfourteen' );

                        endif;
                    ?>
                </h1>
            </header><!-- .page-header -->

            <?php
                    // Start the Loop.
                    while ( have_posts() ) : the_post();

                        /*
                         * Include the post format-specific template for the content. If you want to
                         * use this in a child theme, then include a file called called content-___.php
                         * (where ___ is the post format) and that will be used instead.
                         */
                        get_template_part( 'content', get_post_format() );

                    endwhile;
                    // Previous/next page navigation.
                    twentyfourteen_paging_nav();

                else :
                    // If no content, include the "No posts found" template.
                    get_template_part( 'content', 'none' );

                endif;
            ?>
        </div><!-- #content -->
    </section><!-- #primary -->

<?php
get_sidebar( 'content' );
get_sidebar();
get_footer();
2

You should take a look at content.php and do a check for is_post_type_archive() on whatever you want to hide. For example to hide the entry-meta section, you can do the following:

<?php if ( !is_post_type_archive() ) { ?>
    <div class="entry-meta">
        <?php
            if ( 'post' == get_post_type() )
                twentyfourteen_posted_on();

            if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :
        ?>
        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>
        <?php
            endif;

            edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
        ?>
    </div><!-- .entry-meta -->
<?php } ?>
|improve this answer|||||
1

I would simply do the following.

First, in a child theme, copy the content.php from twentyfourteen to your child theme. Rename it to something like content-archive.php. Now open it up and delete eveything that you don't need, just keeping what is neccesary.

Secondly, copy archive.php to your child theme, open it up and change the following line

get_template_part( 'content', get_post_format() );

To

get_template_part( 'content', 'archive' );

This is all that is needed. No need to have that amount of conditionals in content.php.

|improve this answer|||||
  • +1 but wouldn't you need to copy over the category.php and any other archive files you want to effect rather than just the archive.php file? – Brad Dalton May 19 '14 at 7:51
  • I don't see that been neccesary, the OP wants only archive.php according to his question. This is up to the OP what he needs extra. category.php can be copied and modified if the OP deems it neccesary to display his category pages in the same way, the same goes for any other archive pages he might want. – Pieter Goosen May 19 '14 at 7:58
0

Renny's answer is heading in the right direction, but seeing as you don't know PHP, inserting some of the code could prove a hassle.

Here's the full changed code for content.php in 2014, it will only show the title and categories. I've also used is_archive(), as is_post_type_archive() only works when you actually supply it with a post type.

<?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php twentyfourteen_post_thumbnail(); ?>

    <header class="entry-header">
        <?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
        <div class="entry-meta">
            <span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
        </div>
        <?php
            endif;

            if ( is_single() ) :
                the_title( '<h1 class="entry-title">', '</h1>' );
            else :
                the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
            endif;
        ?>
        <?php if ( !is_archive() ) { ?>
        <div class="entry-meta">
            <?php
                if ( 'post' == get_post_type() )
                    twentyfourteen_posted_on();

                if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :
            ?>
            <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>
            <?php
                endif;

                edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
            ?>
        </div><!-- .entry-meta -->
        <?php } ?>
    </header><!-- .entry-header -->

    <?php 
    if ( !is_archive() ) {
        if ( is_search() ) : ?>
        <div class="entry-summary">
            <?php the_excerpt(); ?>
        </div><!-- .entry-summary -->
        <?php else : ?>
        <div class="entry-content">
            <?php
                the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
                wp_link_pages( array(
                    'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
                    'after'       => '</div>',
                    'link_before' => '<span>',
                    'link_after'  => '</span>',
                ) );
            ?>
        </div><!-- .entry-content -->
        <?php endif; ?>

        <?php the_tags( '<footer class="entry-meta"><span class="tag-links">', '', '</span></footer>' );
    }
        ?>

</article><!-- #post-## -->

The month getting output at the top is part of archive.php - might be worth leaving it there or people will have no idea what archive they are viewing.

|improve this answer|||||
  • Perfect! I tried this out and it worked. The only issue I'm having is in finding the content.php file... it doesn't seem to be in the twentyfourteen theme; I could only find it through the editor on the wordpress dashboard. But I should be saving this to my child theme right? If so, do I just create a new file also called content.php in the child theme folder? – user1985189 May 31 '14 at 20:44
  • Sorry I didn't see this reply until later - if you place content.php in a chile theme it will override the content.php in 2014. Good work on using a child theme (it's the right way to make these sorts of changes) – aj-adl Jul 15 '14 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.