admin管理员组文章数量:1326304
There's an external website that I'll be referencing within my posts that uses the same static format for their pages. Let's say it's website/view/1111, website/view/1112, etc.
What I want to do is create a post template that will automatically append a link to that external site above the post content. So, for example, if my post was titled 1337, the post would automatically include a link at the top "View on website" that would point to website/view/1337.
Alternatively, if that's not feasible to include in a template file, it'd be fine if it were just a shortcode I could use at the beginning of posts.
I tried adding <?php echo “<a href='website/view/<?php the_title(); ?>’>View on website</a>” ; ?>
in my template and that broke the site, so, guessing I did not do that properly.
There's an external website that I'll be referencing within my posts that uses the same static format for their pages. Let's say it's website/view/1111, website/view/1112, etc.
What I want to do is create a post template that will automatically append a link to that external site above the post content. So, for example, if my post was titled 1337, the post would automatically include a link at the top "View on website" that would point to website/view/1337.
Alternatively, if that's not feasible to include in a template file, it'd be fine if it were just a shortcode I could use at the beginning of posts.
I tried adding <?php echo “<a href='website/view/<?php the_title(); ?>’>View on website</a>” ; ?>
in my template and that broke the site, so, guessing I did not do that properly.
1 Answer
Reset to default 2OH I figured it out.
<?php $myvariable = get_the_title( ''. '', false );
echo "<a href='website/view/$myvariable'>View on website</a>";
?>
Hopefully this helps someone else!
本文标签:
版权声明:本文标题:shortcode - Adding variable for post title so post template can include auto-generated link to view on external website.com{post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742207104a2433020.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论