How to limit post content and remove image caption from it

Image captions in WordPress are actually shortcodes. Shortcodes are applied by the filter: $content = apply_filters(‘the_content’, $content); For example, WordPress creates the following code in your content when you enter an image caption: You need to still use apply_filters() in order to properly display content. (safe content display and all other shortcodes) If you don’t … Read more

Add default content to post (for specific category)

default_content runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you’d want the save_post hook, probably. You want to check the $_REQUEST global. add_filter( ‘default_content’, ‘my_editor_content’ ); function my_editor_content( $content ) { global $_REQUEST; if (isset($_REQUEST[‘post_category’]) && in_array($some_category_id,$_REQUEST[‘post_category’])) { $content = “My html … Read more

Edit the_content function

Not exactly sure what you are trying to accomplish, but it looks like you are trying to prepend something to the beginning of the_content. Try this: add_filter(‘the_content’, ‘se24265_my_function’); function se24265_my_function( $content ) { $write=”hello world”; $new_content = $write . $content; return $new_content; } Most filters will provide a parameter or two for your function to … Read more

append_content help

Edited, try this <?php function parse_twitter_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) { $feed = str_replace(“&lt;”, “<“, $feed); $feed = str_replace(“&gt;”, “>”, $feed); $clean = explode(“<content type=\”html\”>”, $feed); $amount = count($clean) – 1; $output = $prefix; for ($i = 1; $i <= $amount; $i++) { $cleaner = explode(“</content>”, $clean[$i]); $output .= $tweetprefix; $output .= $cleaner[0]; $output .= … Read more

JSON not valid after json_encode posts

Newlines are not valid inside json strings. However you are outputting this code or otherwise checking it for sanity is somehow adding newlines into your long strings here. Check that your strings really are all one line and not broken up into multiple lines.

Have multiple local wordpress installs share a wp-content folder and database

For wp-content folder you need to add WP_CONTENT_DIR with path to this folder to each wp-config.php file of each your sites. All of these WP_CONTENT_DIR constants should have the same path to one folder. Read more about it here: http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content To share the same database, you just need to setup the same database settings in … Read more