• I’ve been struggling to include custom field content into the_content.

    I came across this helpful post using add_filter to hook into the_content.

    http://wordpress.org/support/topic/290591?replies=3

    I created a content modifier function and added it to the functions.php file;

    function custom_content($content) {
    	global $post; global $wp_query;
    	if (is_syndicated()):
    		$vidstr=get_post_meta($post->ID,'Video', true);
    			if (!is_null($vidstr)):
    				$findstring="&feature=youtube_gdata";
    				$findit=(string)$findstring;
    					if (strpos($vidstr, $findit) !== false) {
    						$vidstr=str_replace("&feature=youtube_gdata","",$vidstr);
    						$vidstr=str_replace("http://","httpv://",$vidstr);
    						$extracontent = "<b/>".$vidstr;
    						}
    				$findstring="(/feeds/base/videos/";
    				$findit=(string)$findstring;
    				if (strpos($vidstr, $findit) !== false) {
    					$vidstr=str_replace("gdata.youtbue.com/feeds/base/videos/","www.youtube.com/watch?v=",$vidstr);
    					$vidstr=str_replace("http://","httpv://",$vidstr);
    					$extracontent = "<b/>".$vidstr;
    					}
    			endif;
    	endif;
    	$original = $content;
    	$content .= $extracontent;
    	$content .= $original;
    return $content;
    }
    add_filter('the_content', 'custom_content');

    The code above works if I add it to the single.php file directly, however the content will be outside “the_content” where I need to apply some plugins to the output.

    and in the single.php I just have

    the_content('');

    However, no matter what I do I cannot modify the_content to include the content modification above or any other modifications, no matter how simple.

    Could somebody point me in the right direction please ?

    Thanks you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Nic Windley

    (@nisiwi)

    aha! found the problem

    feedwordpress blocks aditional filters so either set;

    Syndicated Posts & Links Settings
    Formatting filters: Exposes syndicated posts to formating filters

    OR in functions.php add;

    remove_filter(‘the_content’, ‘feedwordpress_preserve_syndicated_content’, -10000);
    remove_filter(‘the_content’, ‘feedwordpress_restore_syndicated_content’, 10000);

    now you have control over your content again

    Hey there nisiwi

    I am trying to do similar at http://www.sendandreturn.co.uk/dj-producer/category/7skies-one-2-trance/ where I am using feedwordpress.

    I have gained access to custom fields and can display them within individual posts (it’s just an mp3), but I’d like to display them at category level (in the excerpts or preferably content)

    thanks (in the UK too)

    Jason Paul

    (@jasontrasaterracom)

    ah, so close. I’m trying to do exactly the same thing. Getting Audio from media in FeedWordpress feeds into the Content. removing the filter didn’t work for some reason. Getting media from the feed inside the post instead of outside is proving to be particularly challenging.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘including custom fields in the_content for posts’ is closed to new replies.