Saturday, 28 December 2013 23:19

Modify wordpress post using filter

Written by 
Rate this item
(0 votes)
It's possible to insert any kind of content in wordpress post or page using
short codes, but if you want to inject/modify content in post in more
advanced manner then there is a alternative is using filter
here i show how to do it using "the_content" filter - In your plugin add these codes -
function my_plugin_post_filter($content) { // assuming you created a page or post entitled 'my_certain_post' if ($GLOBALS['post']->post_name == 'my_certain_post') { return var_export($GLOBALS['post'], TRUE ); // you can add your modification logic here } // else returns database content return $content; } add_filter( 'the_content', 'my_plugin_post_filter' ); // filter declaration

For more filters, read the doc - http://codex.wordpress.org/Plugin_API/Filter_Reference

hope that helps to get idea before doing something big, If you have more questions, post
in forum in this site to get sorted out.
Read 2725 times Last modified on Saturday, 28 December 2013 23:35
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.