Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1390561
    childrenscancer
    Participant

    Hi,

    I’ve been working on our new site and would like to customize the search results page. There are two things I’m hoping you might be able to help me with…

    1. How do I get page results to show up like post results? Right now, the page results just include the title of the page. Post results however have the first few lines of the post and a link to read more.

    2. My second question is how do I make the title of each search result a link to the article? Right now the only way you can get to the result is by clicking “read more”. I’d like them to be able to click on the title as well.

    Thank you!

    #1390629
    Rahul
    Moderator

    Hey There,

    Thanks for writing in!

    To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1390756
    childrenscancer
    Participant
    This reply has been marked as private.
    #1390763
    childrenscancer
    Participant

    Here’s an example of a search results page:

    http://dev.childrenscancer.org/?s=leukemia

    As you’ll see a few of the results only have a title – those are pages. Posts are displaying a title, meta, description, and read more.

    #1391322
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! This happens because normal pages doesn’t have an excerpt by default. To be able to have an excerpts for pages, please follow this link: http://www.wpbeginner.com/plugins/add-excerpts-to-your-pages-in-wordpress/

    Hope this helps.

    #1391973
    childrenscancer
    Participant

    That helps part of the problem – thank you. The other part is that the titles don’t link to the articles. How do I make sure all search results have titles that link to that page?

    Thanks!

    #1392108
    childrenscancer
    Participant

    Hi, I read the link you posted and added that bit of code to the functions.php file on my child theme, but it didn’t seem to add an excerpt to the search results. Any other ideas?

    #1392718
    Rad
    Moderator

    Hi there,

    You need to manually add excerpt to those pages. It only add excerpt for page type since it’s originally doesn’t have the excerpt, page is different from post. Edit those page and find Screen Option on top of the page, then make sure Excerpt is toggled on, then scroll down and find Excerpt section and manually add your text excerpt.

    About the title with no links, it’s because of your custom content.php. Please change it to this

    <?php
    
    // =============================================================================
    // VIEWS/INTEGRITY/CONTENT.PHP
    // -----------------------------------------------------------------------------
    // Standard post output for Integrity.
    // =============================================================================
    
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    <?php if( is_singular() ) : ?>
    <h1 class="blog-title"><?php the_title(); ?></h1>
    <?php else : ?>        
    <a href="<?php the_permalink(); ?>"><h2 class="blog-title"><?php the_title(); ?></h2></a>
    <?php endif; ?>
    
      <div class="entry-featured">
        <?php x_featured_image(); ?>
      </div>
            <?php x_integrity_entry_meta(); ?>
      <div class="entry-wrap">
        <?php x_get_view( 'global', '_content' ); ?>
      </div>
      <?php x_get_view( 'integrity', '_content', 'post-footer' ); ?>
    </article>

    Hope this helps.

    #1393277
    childrenscancer
    Participant

    That was really helpful. Everything is working well now. Thank you!

    #1393357
    Rahul
    Moderator

    Glad to hear it!

    Feel free to ask us again if you have any further queries regarding the X-theme.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-1390561 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>