首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wordpress博客标题url

wordpress博客标题url
EN

Stack Overflow用户
提问于 2015-09-30 20:43:30
回答 1查看 87关注 0票数 2

我正在尝试使我的博客标题链接到预览区域的完整帖子,以便标题应该具有与阅读更多按钮相同的功能。博客采用砖石布局,我使用的是themeforest主题。

这是博客页面。

我相信这是控制布局的php代码-希望它能有所帮助。

抱歉,php新手在这里。

我尝试过使用<a href="'.get_permalink().'"><h5 class="post-title">'. get_the_title() .'</h5></a>';,但这只会生成一个包含‘.get_permalink().’的破碎url。“

谢谢

代码语言:javascript
复制
                    <?php if ( '' != get_the_title() ): ?>
        <h5 class="post-title"><?php the_title(); ?></h5>
    <?php endif ?>
    <?php if (has_post_format('link')): ?>
        <a href="<?php echo $nz_link_url; ?>" title="<?php echo __("Go to", TEMPNAME).' '.$nz_link_url; ?>" target="_blank"><?php echo __("Read more", TEMPNAME); ?><span class="icon-arrow-right9"></span></a>
    <?php else: ?>
        <a href="<?php the_permalink(); ?>" title="<?php echo __("Read more about", TEMPNAME).' '.get_the_title(); ?>" rel="bookmark"><?php echo __("Read more", TEMPNAME); ?><span class="icon-arrow-right9"></span></a>
    <?php endif ?>
<?php endif; ?>

EN

回答 1

Stack Overflow用户

发布于 2015-09-30 20:54:03

您只需要将h5标题包装在代码片段的第37行的锚定标记<a>中。要更改的特定代码为:

新答案

代码语言:javascript
复制
<a href="<?php get_permalink(); ?>">
    <h5 class="post-title"><?php the_title(); ?></h5>
</a>

或者从你的代码中,尝试:

代码语言:javascript
复制
<a href="<?php echo $nz_link_url; ?>" title="<?php echo __("Go to", TEMPNAME).' '.$nz_link_url; ?>">
    <h5 class="post-title"><?php the_title(); ?></h5>
</a>

老答案

代码语言:javascript
复制
if ( '' != get_the_title() ){
    $output .= '<a href="'.get_permalink().'"><h5 class="post-title">'. get_the_title() .'</h5></a>';
}

您可能需要更新CSS以反映H5前面的锚标记。

完整代码

代码语言:javascript
复制
 while($recent_posts->have_posts()) : $recent_posts->the_post();

                $output .= '<div class="post format-'.get_post_format().'" data-grid="ninzio_01">';

                    $output .= '<div class="post-wrap nz-clearfix">';

                        if (get_post_format() == 'image') {
                            $values = get_post_custom( $post->ID );
                            $nz_image_url = isset($values["image_url"][0]) ? $values["image_url"][0] : "";

                            if (!empty($nz_image_url)) {
                                $output .='<a class="nz-more" href="'.get_permalink().'">';
                                    $output .= '<div class="nz-thumbnail">';
                                        $output .= '<img src="'.$nz_image_url.'" alt="'.get_the_title().'">';
                                        $output .= '<div class="ninzio-overlay"></div>';
                                        $output .= '<div class="post-date"><span>'.get_the_date("d").'</span><span>'.get_the_date("M").'</span></div>';
                                    $output .='</div>';
                                $output .='</a>';
                            }

                        } else {
                            if (has_post_thumbnail()) {
                                $output .='<a class="nz-more" href="'.get_permalink().'">';
                                    $output .= '<div class="nz-thumbnail">';
                                        $output .= get_the_post_thumbnail( $post->ID, $size );
                                        $output .= '<div class="ninzio-overlay"></div>';
                                        $output .= '<div class="post-date"><span>'.get_the_date("d").'</span><span>'.get_the_date("M").'</span></div>';
                                    $output .='</div>';
                                $output .='</a>';
                            }
                        }



                        $output .= '<div class="post-body">';

                                if ( '' != get_the_title() ){
                                    $output .= '<a href="'.get_permalink().'"><h5 class="post-title">'. get_the_title() .'</h5></a>';
                                }

                                if ($excerpt == "true") {
                                    $output .= '<div class="post-excerpt">'.nz_excerpt(95).'</div>';
                                }

                                $output .='<a href="'.get_permalink().'" title="'.__("Read more about", TEMPNAME).' '.get_the_title().'" rel="bookmark">'.__("Read more", TEMPNAME).' <span class="icon-arrow-right9"></span></a>';

                        $output .= '</div>';

                    $output .= '</div>';

                $output .= '</div>';
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32866452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档