• Resolved spiros

    (@spiros)


    In a different theme (Penscratch 2) I used this in order to display category archives as a list of page titles (below any category description content). How can I have the same results with generatepress? Its archives.php seems quite different.

    <?php
    get_header(); ?>
    
    	<section id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    		<?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<?php
    					the_archive_title( '<h1 class="page-title">', '</h1>' );
    					the_archive_description( '<div class="archive-description">', '</div>' );
    				?>
    			</header><!-- .page-header -->
    <ol>
    			<?php
            // Start the Loop.
            while ( have_posts() ) : the_post();
    ?> 
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ol>
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    		</main><!-- #main -->
    	</section><!-- #primary -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi there,

    just to confirm – you simply want to display the Post Titles, and nothing else for the individual posts in the archive ( ie. no featured image, no excerpt, no meta ) ?

    Thread Starter spiros

    (@spiros)

    yes, and of course maintain any added category content on top.

    If you check the code I posted, it just outputs the loop in an ordered list like this:

    <ol>
    <?php
            // Start the Loop.
            while ( have_posts() ) : the_post();
    ?> 
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ol>
    • This reply was modified 2 years, 11 months ago by spiros.

    For your needs it may be easiest to copy the archive.php and swap out just the GP loop without own ie. replace these lines with your :

    https://github.com/tomusborne/generatepress/blob/a3ce1712ab1cc705fed577fad8fa9ea8c04d5d20/archive.php#L43-L49

    <ol>
    <?php
            // Start the Loop.
            while ( have_posts() ) : the_post();
    ?> 
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ol>
    Thread Starter spiros

    (@spiros)

    Thanks, I tried with the code and I get a critical error no matter what changes I make

    do_action( 'generate_archive_title' );
    
    /**
    * generate_before_loop hook.
    *
    * @since 3.1.0
    */
    do_action( 'generate_before_loop', 'archive' );
    <ol>
            while ( have_posts() ) : the_post();
    
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    endwhile;
    </ol>
    
    /**
    * generate_after_loop hook.
    *
    * @since 2.3
    */
    do_action( 'generate_after_loop', 'archive' );
    
    else :
    
    generate_do_template_part( 'none' );
    
    endif;
    			}
    • This reply was modified 2 years, 11 months ago by spiros.
    ying

    (@yingscarlett)

    Try replace the original code of the theme file with the code David provided, as your current code is missing some <?php and ?>.

    Thread Starter spiros

    (@spiros)

    Yes, I had tried originally with those, and had the same error.

    ying

    (@yingscarlett)

    Try this:

    
    ?><ol>
    <?php
            // Start the Loop.
            while ( have_posts() ) : the_post();
    ?> 
    <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ol> 
    <?php
    
    Thread Starter spiros

    (@spiros)

    Thanks! That worked.

    ying

    (@yingscarlett)

    No problem ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Archive output as list of page titles only’ is closed to new replies.