WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Twelve
[resolved] How to remove page title + feat image from page but not "search page" results? (9 posts)

  1. kpenn
    Member
    Posted 1 year ago #

    How to remove page title and featured image from page(s) but not website's search page results?

    I would like to see the page title and featured image when page is pulled up in website's search results BUT don't want title or featured image to show on actual page.

    WAS ABLE TO REMOVE FROM ACTUAL PAGE(S)
    The following codes helped me accomplish this -

    /* Remove page title from home *\
    .home .entry-title {
        display: none;
    }
    /* Remove page title from page *\
    .page .entry-title {
        display: none;
    }
    /* Remove featured image from home *\
    .home .entry-header {
        display: none;
    }
    /* Remove featured image from page *\
    .page .entry-header {
        display: none;
    }

    PROBLEM WITH THIS APPROACH
    It also removed the featured images and page titles from the website's search results (when typing keyword in search widget).

    fyi - blog post view fine in search results / did not remove title and featured images from blog post - want them there.

    Oh, and yes I'm using a child theme.

    Any help appreciated.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Do not edit the Twenty Twelve theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes. Or install a custom CSS plugin.

  3. kpenn
    Member
    Posted 1 year ago #

    Yes I'm using a child theme - thank you.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Sorry - missed that bit! :-)

    Try using Firefox with the Firebug add-on for this kind of CSS troubleshooting. Or use whatever developer tool is available in your web browser.

    I'd also suggest that you do not use display:none; to hide content as this will also hide it from non-graphical users such as Googlebot. Try using negative text indent or absolute positioning instead - e.g:

    /* Remove page title from home *\
    .home .entry-title {
    position:absolute;
    top:-9999px;
    left:-9999px;
    }
  5. kpenn
    Member
    Posted 1 year ago #

    Thank you for that tip (display: none; also hides from Googlebot) - made adjustments and worked fine.

    I am using fire bug, that is how I located .page entry-title and .page entry-header.

    Problem being

    .page .entry-title {
    	position:absolute;
    top:-9999px;
    left:-9999px;
    }
    
    .page .entry-header {
    	position:absolute;
    top:-9999px;
    left:-9999px;
    }

    Also removes/hide "Page Title" and "Featured Image" from page list populated in search results or "Archive".

    Thinking some sought of conditional code (?code) may need to be added to php file (?file) - so it would only show "Page Title" and "Featured Image" in "Archive" but not on actual page. (would like for title and featured image serve as page preview in archive as they do for blog post on blog page but again, remain hidden on actual page)

  6. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You could have a look at using is_archive() and/or is_single() in your child's content.php template file.
    http://codex.wordpress.org/Conditional_Tags

  7. kpenn
    Member
    Posted 1 year ago #

    There we go - looks like a good point in direction. About to check it out. Thank you.

  8. kpenn
    Member
    Posted 1 year ago #

    Got it!

    Used is_page() in child's content-page.php

    In content-page.php CHANGED:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<header class="entry-header">
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    		</header>

    TO THIS:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<?php if(!is_page()): ?>
    		<header class="entry-header">
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    		</header>
    		<?php endif; ?>

    Now the page titles are removed from the actual pages but show up to help identify the page in search results.

    Again, thanks for the point in direction.

  9. kpenn
    Member
    Posted 1 year ago #

    Resolved

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic