WordPress.org

Ready to get started?Download WordPress

Forums

Search Results page is outputting h1 tags for each listing (9 posts)

  1. jamieb7210
    Member
    Posted 1 year ago #

    On my search results page, I have a page title (Search Results) that's in an h1 tag; however, all the results returned in a search, their titles are also in h1 tags, so my search results page has about 15 h1 tags on it when it really should be in h2 tags. Is there an easy way to have the search result titles display in h2 tags just on this page?

  2. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    Which theme are you using?

  3. jamieb7210
    Member
    Posted 1 year ago #

    twenty eleven

  4. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    As this is part of the theme, you'll need to create a Child Theme and modify the HTML elements in which the search results template uses, to use <h2> in stead of <h1>.

  5. jamieb7210
    Member
    Posted 1 year ago #

    I've never used that before; can you tell me how I would change it so that it only affects the search results and not all of the pages?

  6. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    You'll need to duplicate the search results template into your Child Theme. Then edit this duplicate file.

  7. jamieb7210
    Member
    Posted 1 year ago #

    Here is the template information; can you tell me what exactly I need to edit to make the title of each search result display in an h2 tag?

    <header class="page-header">
    					<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyeleven' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    				</header>
    
    				<?php twentyeleven_content_nav( 'nav-above' ); ?>
    
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    					?>
    
    				<?php endwhile; ?>
  8. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    Here is the template information;

    Is this the file header.php ?

  9. jamieb7210
    Member
    Posted 1 year ago #

    this is the search.php page.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.