Search Results No Link

admin2025-06-03  3

The search results page is not showing a link that the user can click on. I am needing the heading to be the link.

Does anyone know what the issue might be?

Below is my search.php and content.php code...

SEARCH.PHP

    <?php
/**
 * The template for displaying Search Results pages
 *
 * @package WordPress
 * @subpackage Cornerstone
 * @since Cornerstone 3.0.0
 */

get_header(); ?>

<div class="row">
    <section id="primary" class="site-content small-12 medium-8 columns">
        <div id="content" role="main">

        <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'cornerstone' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
            </header>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', get_post_format() ); ?>
            <?php endwhile; ?>

        <?php else : ?>

            <article id="post-0" class="post no-results not-found">
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'cornerstone' ); ?></h1>
                </header>

                <div class="entry-content">
                    <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'cornerstone' ); ?></p>
                    <?php get_search_form(); ?>
                </div>
            </article>

            <?php do_action( 'cornerstone_before_pagination' ); ?>

        <?php endif; ?>

        <?php // Pagination
            if (function_exists("emm_paginate")) {
            emm_paginate();
        } ?>

        <?php do_action( 'cornerstone_after_content' ); ?>

        </div>
    </section>

    <?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

CONTENT.PHP

<?php
/**
* The default template for displaying content. Used for both single and 
index/archive/search.
 *
* @package WordPress
* @subpackage Cornerstone
* @since Cornerstone 2.2.2
*/
?>

<div class="row searchresults">

<div class="small-12 columns">

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    <div class="featured-post">
        <?php _e( 'Featured post', 'cornerstone' ); ?>
    </div>
    <?php endif; ?>

<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">

    <div class="entry">
<?php $content = get_the_content();
  $content = strip_tags($content);
  echo '<p>' . substr($content, 0, 255) . ' [...] </p>';
?>

<hr class="post-divider"/>
</div>

</div>
<?php else : ?>
<?php do_action( 'cornerstone_page_before_entry_content' ); ?>
<div class="entry-content">
    <?php if ( has_post_thumbnail() ) { ?>
        <a href="<?php the_permalink(); ?>" class="featurimaglink" title="<? 
php the_title(); ?>"> <div class="post-featured-img"><?php 
the_post_thumbnail(); 
?></div> </a>

            <header class="entry-header">
                <?php if ( is_single() ) : ?>
                    <!-- Do Nothing: all got moved to "single.php" -->          
                <?php else : ?>
                <strong>
                    <a href="<?php the_permalink(); ?>" title="<?php echo 
esc_attr( sprintf( __( 'Permalink to %s', 'cornerstone' ), 
the_title_attribute( 
'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>


                    <?php 
                    if (is_category('blog') || is_category('news') ) {
                    ?>

                    <div class="aftertcnt">
                        <span><?php echo get_the_date(); ?></span>
                    </div>

                    <?php
                    }
                    ?>

                </strong>
                <?php endif; // is_single() ?>
            </header>

    <?php } else  { ?>  
    <?php }?> 

    <?php if (is_category()): ?>
        <?php the_excerpt(); ?> 
    <?php else: ?>
        <?php the_content( __( 'Continue reading <span class="meta- 
nav">&rarr;</span>', 'cornerstone' ) ); ?>
    <?php endif ?>


    <?php if (is_single() && in_category( 'blog' )  ) { ?>
        <div class="singleview">
        <a href="<?php bloginfo('url'); ?>/blog" title="View All News" 
class="button">View All Blog</a>
        </div> 

    <?php } else if (is_single()) { ?>  
        <div class="blogview">
        <a href="<?php bloginfo('url'); ?>/news" title="<?php the_title(); ? 
>" class="button">View All News</a>
        </div>

    <?php } else  { ?>  
        <div class="blogview">
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" 
class="button">Read More</a>
        </div>

    <?php }?> 

    <?php 
    if ( is_category('blog')  || is_category('news') ) {
    ?>

    <hr class="post-cat-divider"/>

    <?php
    }
    ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 
'Pages:', 'cornerstone' ), 'after' => '</div>' ) ); ?>
</div>
<?php do_action( 'cornerstone_page_after_entry_content' ); ?>
<?php endif; ?>
</div>
</div>

<div class="entry-meta">
    <?php edit_post_link( __( 'Edit', 'cornerstone' ), '<span class="edit- 
link">', '</span>' ); ?>
</div>

</article>

The search results page is not showing a link that the user can click on. I am needing the heading to be the link.

Does anyone know what the issue might be?

Below is my search.php and content.php code...

SEARCH.PHP

    <?php
/**
 * The template for displaying Search Results pages
 *
 * @package WordPress
 * @subpackage Cornerstone
 * @since Cornerstone 3.0.0
 */

get_header(); ?>

<div class="row">
    <section id="primary" class="site-content small-12 medium-8 columns">
        <div id="content" role="main">

        <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'cornerstone' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
            </header>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', get_post_format() ); ?>
            <?php endwhile; ?>

        <?php else : ?>

            <article id="post-0" class="post no-results not-found">
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'cornerstone' ); ?></h1>
                </header>

                <div class="entry-content">
                    <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'cornerstone' ); ?></p>
                    <?php get_search_form(); ?>
                </div>
            </article>

            <?php do_action( 'cornerstone_before_pagination' ); ?>

        <?php endif; ?>

        <?php // Pagination
            if (function_exists("emm_paginate")) {
            emm_paginate();
        } ?>

        <?php do_action( 'cornerstone_after_content' ); ?>

        </div>
    </section>

    <?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

CONTENT.PHP

<?php
/**
* The default template for displaying content. Used for both single and 
index/archive/search.
 *
* @package WordPress
* @subpackage Cornerstone
* @since Cornerstone 2.2.2
*/
?>

<div class="row searchresults">

<div class="small-12 columns">

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    <div class="featured-post">
        <?php _e( 'Featured post', 'cornerstone' ); ?>
    </div>
    <?php endif; ?>

<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">

    <div class="entry">
<?php $content = get_the_content();
  $content = strip_tags($content);
  echo '<p>' . substr($content, 0, 255) . ' [...] </p>';
?>

<hr class="post-divider"/>
</div>

</div>
<?php else : ?>
<?php do_action( 'cornerstone_page_before_entry_content' ); ?>
<div class="entry-content">
    <?php if ( has_post_thumbnail() ) { ?>
        <a href="<?php the_permalink(); ?>" class="featurimaglink" title="<? 
php the_title(); ?>"> <div class="post-featured-img"><?php 
the_post_thumbnail(); 
?></div> </a>

            <header class="entry-header">
                <?php if ( is_single() ) : ?>
                    <!-- Do Nothing: all got moved to "single.php" -->          
                <?php else : ?>
                <strong>
                    <a href="<?php the_permalink(); ?>" title="<?php echo 
esc_attr( sprintf( __( 'Permalink to %s', 'cornerstone' ), 
the_title_attribute( 
'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>


                    <?php 
                    if (is_category('blog') || is_category('news') ) {
                    ?>

                    <div class="aftertcnt">
                        <span><?php echo get_the_date(); ?></span>
                    </div>

                    <?php
                    }
                    ?>

                </strong>
                <?php endif; // is_single() ?>
            </header>

    <?php } else  { ?>  
    <?php }?> 

    <?php if (is_category()): ?>
        <?php the_excerpt(); ?> 
    <?php else: ?>
        <?php the_content( __( 'Continue reading <span class="meta- 
nav">&rarr;</span>', 'cornerstone' ) ); ?>
    <?php endif ?>


    <?php if (is_single() && in_category( 'blog' )  ) { ?>
        <div class="singleview">
        <a href="<?php bloginfo('url'); ?>/blog" title="View All News" 
class="button">View All Blog</a>
        </div> 

    <?php } else if (is_single()) { ?>  
        <div class="blogview">
        <a href="<?php bloginfo('url'); ?>/news" title="<?php the_title(); ? 
>" class="button">View All News</a>
        </div>

    <?php } else  { ?>  
        <div class="blogview">
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" 
class="button">Read More</a>
        </div>

    <?php }?> 

    <?php 
    if ( is_category('blog')  || is_category('news') ) {
    ?>

    <hr class="post-cat-divider"/>

    <?php
    }
    ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 
'Pages:', 'cornerstone' ), 'after' => '</div>' ) ); ?>
</div>
<?php do_action( 'cornerstone_page_after_entry_content' ); ?>
<?php endif; ?>
</div>
</div>

<div class="entry-meta">
    <?php edit_post_link( __( 'Edit', 'cornerstone' ), '<span class="edit- 
link">', '</span>' ); ?>
</div>

</article>
Share Improve this question edited Feb 1, 2019 at 19:14 Webman asked Jan 31, 2019 at 22:26 WebmanWebman 631 silver badge11 bronze badges 2
  • The code that would determine this isn't here. It's inside the file included on this line: <?php get_template_part( 'content', get_post_format() ); ?> So content.php. – Jacob Peattie Commented Feb 1, 2019 at 0:25
  • I edited my original question and added the CONTENT.PHP code. You will see this content.php file has been changed. This was for a different customization for article related pages (blogs and news). I see the section that mentions "// Only display Excerpts for Search", but I am not sure how to also display the page/article headline, and make it a link. – Webman Commented Feb 1, 2019 at 19:07
Add a comment  | 

1 Answer 1

Reset to default 2

The problem is in this part

<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">

    <div class="entry">
<?php $content = get_the_content();
  $content = strip_tags($content);
  echo '<p>' . substr($content, 0, 255) . ' [...] </p>';
?>

<hr class="post-divider"/>
</div>

</div>
<?php else : ?>

You need to add a link somewhere in there, like so:

<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">

    <div class="entry">
<?php $content = get_the_content();
  $content = strip_tags($content);
  echo '<p>' . substr($content, 0, 255) . ' [...] </p>';
?>
<a href="<?php echo get_the_permalink(); ?>">Read More</a>

<hr class="post-divider"/>
</div>

</div>
<?php else : ?>

Then you can modify the location and content of that link as you like.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748952608a315107.html

最新回复(0)