制作标题和[...]在结果搜索中可点击

时间:2014-10-24 作者:User01

我的网站上有搜索引擎。但是当我尝试搜索一些东西时,比如“loan”,标题是不可点击的,其他内容也不会显示出来

如何将内容和标题显示为可单击?

SITE HERE

我正在搜索此代码。php

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

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( \'content\', \'summary\' ); ?>

        <?php endwhile; ?>

        <?php accesspress_ray_paging_nav(); ?>

    <?php else : ?>

        <?php get_template_part( \'content\', \'none\' ); ?>

    <?php endif; ?>
内容摘要。php

    <?php
   global $accesspress_ray_options;
   $accesspress_ray_settings = get_option( \'accesspress_ray_options\',   $accesspress_ray_options );
   $cat_testimonial = $accesspress_ray_settings[\'testimonial_cat\'];
   $cat_portfolio = $accesspress_ray_settings[\'portfolio_cat\'];

if(!empty($cat_testimonial) && is_category() && is_category($cat_testimonial)): ?>
<article id="post-<?php the_ID(); ?>" class="cat-testimonial-list clearfix">
<div class="cat-testimonial-image clearfix">
<?php 
    if( has_post_thumbnail() ){
        $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \'featured-thumbnail\', false ); 
    ?>
    <img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>">
    <?php }else {?> 
    <img src="<?php echo get_template_directory_uri(); ?>/images/testimonial-fallback.png" alt="<?php the_title(); ?>">
    <?php }?>
</div>

<header class="entry-header">
<h3><?php the_title(); ?></h3>
</header><!-- .entry-header -->
<div class="cat-testimonial-excerpt">
        <?php the_content(); ?>
</div>
</article>

<?php elseif(!empty($cat_portfolio) && is_category() && is_category($cat_portfolio)): ?>
<article id="post-<?php the_ID(); ?>" class="cat-portfolio-list">
<?php 
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \'portfolio-  thumbnail\', false ); 
 $full_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \'large\', false ); 
?>
<a href="<?php the_permalink(); ?>" >
<div class="cat-portfolio-image">
    <img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>">
</div>
<div class="portofolio-layout">
    <div class="portofolio-content-wrap">
        <h1><?php the_title(); ?></h1>
        <div class="cat-portfolio-excerpt">
            <?php echo accesspress_ray_excerpt(get_the_content(),\'100\'); ?>
        </div>
    </div>
</div>
</a>
</article>

<?php else: ?>

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

    <?php if ( \'post\' == get_post_type() ) : ?>
    <div class="entry-meta">
        <?php accesspress_ray_posted_on(); ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>
 </header><!-- .entry-header -->

 <?php if ( is_search() ) : // Only display Excerpts for Search ?>
 <div class="entry-summary">
    <?php the_excerpt(); ?>
    <a href="<?php echo get_permalink(); ?>"> Read More...</a>
 </div><!-- .entry-summary -->
 <?php else : ?>
 <div class="entry-content">
    <?php if(has_post_thumbnail()){?>
    <div class="entry-thumbnail">
        <?php  the_post_thumbnail(\'featured-thumbnail\'); ?>
    </div>
    <?php } ?>
    <div class="entry-exrecpt <?php if(!has_post_thumbnail()){ echo "full-width"; }?>">
    <div class="short-content clearfix">
    <?php echo accesspress_ray_excerpt( get_the_content() , 380 ) ?>
    </div>
    <a href="<?php the_permalink(); ?>" class="bttn"><?php _e(\'More\',\'accesspress_ray\')?></a>
    <?php
        wp_link_pages( array(
            \'before\' => \'<div class="page-links">\' . __( \'Pages:\', \'accesspress_ray\' ),
            \'after\'  => \'</div>\',
        ) );
    ?>
    </div>
</div><!-- .entry-content -->
<?php endif; ?>

 <footer class="entry-footer">
    <?php if ( \'post\' == get_post_type() ) : // Hide category and tag text for pages on   Search ?>
        <?php
            /* translators: used between list items, there is a space after the comma */
            $categories_list = get_the_category_list( __( \', \', \'accesspress_ray\' ) );
            if ( $categories_list && accesspress_ray_categorized_blog() ) :
        ?>
        <span class="cat-links">
            <?php printf( __( \'Posted in %1$s\', \'accesspress_ray\' ), $categories_list   ); ?>
        </span>
        <?php endif; // End if categories ?>

        <?php
            /* translators: used between list items, there is a space after the comma    */
            $tags_list = get_the_tag_list( \'\', __( \', \', \'accesspress_ray\' ) );
            if ( $tags_list ) :
        ?>
        <span class="tags-links">
            <?php printf( __( \'Tagged %1$s\', \'accesspress_ray\' ), $tags_list ); ?>
        </span>
        <?php endif; // End if $tags_list ?>
    <?php endif; // End if \'post\' == get_post_type() ?>

    <?php //edit_post_link( __( \'Edit\', \'accesspress_ray\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
<?php endif; ?>

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

至于the_title(), 您可以将标题包装在锚定标记中,使用get_permalink() 获取单个立柱的路径。这样就可以了

the_title( \'<h1 class="entry-title"><a href="\' . esc_url( get_permalink() ) . \'" rel="bookmark">\', \'</a></h1>\' );
有关如何修改/样式的任何信息the_excerpt(), 退房this post 我最近做过。你想知道的一切都应该在那个帖子里

结束