Support » Theme: Quark » What 'get_post_format' does Search.php call for?

  • Resolved jcervantes28


    Hello again Anthony and/or others,

    I am breaking my head over this: I want category, tag, author archives to be shown in such a way that they show:

    Title with link
    meta data and featured image (optional)

    The default shows the entire content, and I don’t want to go back to all of previous posts to add a ‘more’

    So I fiddled around and added this to the category loop:

    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title( '<center><h1>', '</h1></center>' ); ?></a>
    					 <?php if ( has_post_thumbnail()) : ?>
       						<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
       						<?php the_post_thumbnail('thumbnail'); ?>
     						<?php endif; ?><?php the_excerpt(); ?>

    That showed permalinked, centered title, thumbnail, excerpt. I was happy to have done this, though not happy with its styling–the permalink was underlined, and ideally i would want the excerpt wrapped around image.

    But, scratch all of that. If I could just get my archives (all of them) to appear like they do in search results, I’d be happy, even without the featured image.

    However, by examining the search.php, in the loop it calls for:

    <?php get_template_part( 'content', get_post_format() ); ?>

    Which is exactly what the default category archives calls for…So the difference is, what post_format does search results call for?

    I’m out of leads…

    I’d appreciate the help! I love learning all this and researching, but I’ve got no leads now…

    Thank you!


Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Anthony Hortin


    The Post Format for search will be blank, since they don’t have one. So basically, this get_template_part() line (above) will simply call content.php.

    If you look in content.php you’ll see a block of code in between the following ‘if’ statement…

    <?php if ( is_search() ) { // Only display Excerpts for Search ?>
    <?php } ?>


    You pointed me in the right direction! I had seen that piece of code before, but I could not understand what it did…I’m understanding content.php a lot more now.

    I threw in the following between loop’s while and endwhile

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<?php if ( is_sticky() && is_home() && ! is_paged() ) { ?>
    			<div class="featured-post">
    				<?php esc_html_e( 'Featured post', 'quark' ); ?>
    		<?php } ?>
    		<header class="entry-header">
    				<h1 class="entry-title">
    					<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to %s', 'quark' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    			<?php quark_posted_on(); ?>
    		</header> <!-- /.entry-header -->
    			<div class="entry-summary">
    				<?php the_excerpt(); ?>

    And got exactly what I wanted! Thanks man!

    The only difference is that the comments show in category archives now, but not in search. And if I want to, I can play around with throwing in the thumbnail…

    Thank you for your patience and for the help!


    oh and if anyone sees this…after the code i entered above, i had forgotten to add:

    </div> <!-- /.entry-summary -->

    Otherwise that had broken my footer


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘What 'get_post_format' does Search.php call for?’ is closed to new replies.