Insert Specific Page content at the bottom of a post W/O a plugin
-
Hello and thanks for your help in advance.
Goal: Add the entire content of a specific page (that is already made) to the bottom of specific posts, but not all posts.
I’ve used the “bottom of every post” plugin and it doesn’t do what I want as it: 1) puts the content at the bottom of every post and I only want a few, and 2) it consolidates the text instead of keeping it separated as paragraphs as it is on the actual page.
I know there are other plugins, but I’d rather find out if any of you pros out there (Read: a fun challenge) know a code or script I can insert at the bottom of a post’s HTML that will insert the page [content] I want.
I prefer not to use a plugin for (3) reasons:
1) Updates can break or mess with your site.
2) The author could abandon the plugin, leaving one screwed.
3) Plugins can conflict with each other or affect site load times.I found the code below in a 5 year old post, but wouldn’t know where to paste it or if is still valid given the number of changes in the last 5 years.
<—–START CODE——>
<?php
$post_id = 12;
$queried_post = get_post($post_id);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->post_content; ?>You have to change the $post_id number to the post you want to use.
<—–END CODE——>For reference purposes, the page I want to insert into posts is here: https://blog.superstaruniversity.com/chance
Any help or direction would be greatly appreciated.
Thanks,
Alex
- The topic ‘Insert Specific Page content at the bottom of a post W/O a plugin’ is closed to new replies.