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!