• Resolved Abalone

    (@abalone)


    Hello,

    I am trying and failing to change the way the search results are presented. Instead of a listing without images I would like it to look just like every other page, images with post-titles that appear on hovering the image. Thus I just copied some lines of the archive.php and pasted it into the search.php, but it doesn’t work as intended – there are now images, but they are still “listed” and the post-titles are shown right under the images.

    Here are some screenshots – this is what I would like the page to look like: What I want
    and this is what I get: What I get

    And this is the code I replaced – I took this in search.php:

    <?php $counter = 1; ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php do_atomic( 'before_entry' ); // hatch_before_entry ?>
    
    					<?php if ( ( $counter % 2 ) == 0 ) { ?>
    
    						<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?> last">
    
    					<?php } else { ?>
    
    						<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    
    					<?php } ?>
    
    							<?php do_atomic( 'open_entry' ); // hatch_open_entry ?>
    
    							<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
    
    							<?php echo apply_atomic_shortcode( 'byline', '<div class="byline">' . __( '[entry-published] [entry-author]', 'hatch' ) . '</div>' ); ?>
    
    							<div class="entry-summary">
    								<?php the_excerpt(); ?>
    								<?php wp_link_pages( array( 'before' => '<p class="page-links">' . __( 'Pages:', 'hatch' ), 'after' => '</p>' ) ); ?>
    							</div><!-- .entry-summary -->
    
    							<?php do_atomic( 'close_entry' ); // hatch_close_entry ?>
    
    						</div><!-- .hentry -->
    
    					<?php do_atomic( 'after_entry' ); // hatch_after_entry ?>
    
    					<?php $counter++; ?>
    
    				<?php endwhile; ?>

    and replaced it by these lines from archive.php:

    <?php $counter = 1; ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php do_atomic( 'before_entry' ); // hatch_before_entry ?>
    
    					<?php if ( ( $counter % 4 ) == 0 ) { ?>
    
    						<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?> last">
    
    					<?php } else { ?>
    
    						<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    
    					<?php } ?>
    
    							<?php do_atomic( 'open_entry' ); // hatch_open_entry ?>
    
    							<?php if ( current_theme_supports( 'get-the-image' ) ) {
    
    										get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'archive-thumbnail', 'image_class' => 'featured', 'width' => 220, 'height' => 150, 'default_image' => get_template_directory_uri() . '/images/archive_image_placeholder.png' ) );
    
    								} ?>					
    
    								<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
    
    							<?php do_atomic( 'close_entry' ); // hatch_close_entry ?>
    
    						</div><!-- .hentry -->
    
    					<?php do_atomic( 'after_entry' ); // hatch_after_entry ?>
    
    					<?php $counter++; ?>
    
    				<?php endwhile; ?>

    What did I do wrong? Do I have to alter the stylesheet? Or does the search.php has to be registered somewhere?

    Thanks in advance!
    Abalone

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Griden

    (@griden)

    The new search template will need to be styled (CSS) like the archive.php.

    Thread Starter Abalone

    (@abalone)

    Hm, yes, that’s what I thought too. But when I take a look at the output I don’t see any difference in code.

    This is the output of archive.php:

    <div id="content">
    	<div class="hfeed">
    		<div id="post-3275" class="hentry post publish post-4 odd author-xyz category-insekten-insecta category-kaefer-coleoptera category-laufkaefer-carabidae category-neu category-ruedesheim-weinberge">
    		<a href="https://www.xyz.de/ruedesheim-weinberge/feld-sandlaufkaefer-cicindela-campestris-3" title="Feld-Sandlaufk?fer (Cicindela campestris)"><img src="https://www.xyz.de/wp-content/uploads/2013/01/7542995396_12145bef02_o-220x150.jpg" alt="Feld-Sandlaufk?fer (Cicindela campestris)" class="archive-thumbnail featured" width="220" height="150" /></a>
    		<h2 class='post-title entry-title'><a href='https://www.ffh-rheingau.de/ruedesheim-weinberge/feld-sandlaufkaefer-cicindela-campestris-3'>Feld-Sandlaufk?fer (Cicindela campestris)</a></h2>
    		</div><!-- .hentry -->
    	</div><!-- .hfeed -->
    </div><!-- #content -->

    and this of search.php:

    <div id="content">
    	<div class="hfeed">
    		<div id="post-3275" class="hentry post publish post-1 odd author-xyz category-insekten-insecta category-kaefer-coleoptera category-laufkaefer-carabidae category-neu category-ruedesheim-weinberge">
    		<a href="https://www.xyz.de/ruedesheim-weinberge/feld-sandlaufkaefer-cicindela-campestris-3" title="Feld-Sandlaufk?fer (Cicindela campestris)"><img src="https://www.xyz.de/wp-content/uploads/2013/01/7542995396_12145bef02_o-220x150.jpg" alt="Feld-Sandlaufk?fer (Cicindela campestris)" class="archive-thumbnail featured" width="220" height="150" /></a>
    		<h2 class='post-title entry-title'><a href='https://www.ffh-rheingau.de/ruedesheim-weinberge/feld-sandlaufkaefer-cicindela-campestris-3'>Feld-Sandlaufk?fer (Cicindela campestris)</a></h2>
    		</div><!-- .hentry -->
    	</div><!-- .hfeed -->
    </div><!-- #content -->

    No big difference, I don’t see what I could add/change in the stylesheet :-/

    Bye
    Marja

    Thread Starter Abalone

    (@abalone)

    Ok, sorry, I was code-blind this morning ?? It works now.
    In case that someone else wants to know what I missed:
    open style.css, search for all .archive-classes and add .search-classes.

    Goodnight,
    Abalone

    I’m lost! the code from search.php and archive.php are different for me…
    How can I have the archive (homepage) layout for search results?
    Please help!

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change presentation of search results?’ is closed to new replies.