How to embed page content in a blog post
I’ve built an HTML table that is posted on a page in my site, and I’d like to use that same content inside a blog post (something of an announcement of the table’s publication). The table is likely to get updated from time to time, so I’d like to have a single source for maintenance purposes.
Is there a way I can do a one-off embedding of the table’s source into the blog post, so that it is always updated when the page is updated? This isn’t expected to happen often, so I don’t want to put a lot of elbow grease into making this work.
Thanks in advance!
EDIT
SO I made a really short shortcode solution using http://wordpress.org/extend/plugins/shortcode-exec-php/
extract(shortcode_atts(array('arg' => 'default'), $atts));
$id = 2328;
$post = get_post( $id );
return apply_filters('the_content', $post->post_content );
Thanks to everyone who helped. I don’t have rep to upvote answers, but i will when I get more points.
Create a shortcode to embed the content. This will always be synchronized.
Sample code from an older project. Just updated. ๐
GitHub: https://gist.github.com/3380118 รยท This post in German (auf Deutsch) on my blog.
Just make sure not to embed two posts vice versa.
I would look at using the WordPress SHortcode API:
http://codex.wordpress.org/Shortcode_API
This will allow you to create something along the lines of [announceTable] or such so that you can call the table’s data and styling as represented in the original page (which is also the Shortcode). Then when you want to update the table you update the Shortcode itself.
I hope I understood what you wanted and that this helps. Happy programming!
If you are looking for a quick and easy solution you might want to have a look at the WP-Table Reloaded plugin.
That allows users to created as many (or as little) tables as they like that are then displayed by adding a simple shortcode in the page/post content.
As it’s linked to via the shortcode they user can then update the table and it will change everywhere it’s linked to.
I’ve used it with a company website where the content is made up of a lot of technical tables and it’s been great as where have been any changes to specifications I just go to the admin and update the table and it’s then updated everywhere.