第一次打开一个岗位,迫切需要一些帮助。
这个问题可能很简单(很可能),但我想不出过去两天一直在尝试。
因此,我已经在我的wordpress站点中创建了一个新的自定义Post类型,并且正在为Archive创建一个模板,您将在其中看到已经创建的所有帖子。
这里的问题是,我想让标题的帖子显示(这是工作良好),但也是一个链接到帖子本身。我知道有the_shortlink();它工作得很好,但我希望文章本身的标题是链接。
下面是一些文字,写在身体上,有点像预览里面的文章。据我所知,我可以使用the_excerpt();如果这也是错误的,请告诉我。
//Some CSS this is not important atm <div class="aa-div">
<?
if(have_posts()) : while(have_posts()) : the_post();
the_title();
the_shortlink();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile; endif; ?>
</div>
祝你有一个美好的一天和一个快乐的新年。
发布于 2020-01-01 16:18:53
您可以使用以下代码
the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );而不是
the_title();发布于 2020-01-01 15:32:59
您可以使用html元素并将标题链接到post的permalink:
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>发布于 2020-01-01 14:42:28
使用get_post_permalink函数。
<?php echo get_post_permalink() ?>
https://stackoverflow.com/questions/59552883
复制相似问题