Search Results No Link

时间:2019-01-31 作者:Webman

搜索结果页面未显示用户可以单击的链接。我需要标题作为链接。

有人知道问题是什么吗?

下面是我的搜索。php和内容。php代码。。。

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>

1 个回复
最合适的回答,由SO网友:mrben522 整理而成

问题就在这一部分

<?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 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 : ?>
然后,您可以根据需要修改该链接的位置和内容。

相关推荐

Search function not working

我正在为我的woocommerce商店使用SSHOP主题。当我从主页搜索任何内容时,搜索url工作正常,下面的搜索permalink显示。https://techcart.pk/?s=abc但当我从产品页面或分类页面搜索时,搜索结果并没有找到任何内容,下面的permalink显示。https://techcart.pk/product/8mm-led-10pcs/?s=abc我想重写上面的永久链接,如下所示https://techcart.pk/?s=abc请帮忙