• I need to append the content from a couple given post ids, into another specific pages. This is what I’ve tried but it’s not working.

    The goal is to append the content from posts id 1794 and 2094 when you browse the pages with id 2294 and 7362:

    function add_contents($content){global $post;
    	$mystring="";
    	if( is_page(array(2294, 7362)) ){
    		$mystring1 = get_post_field('post_content', 1794);
    		$mystring1 = apply_filters('the_content', $mystring1);
    		$mystring1 = str_replace(']]>', ']]>', $mystring1);
    
    		$mystring2 = get_post_field('post_content', 2094);
    		$mystring2 = apply_filters('the_content', $mystring2);
    		$mystring2 = str_replace(']]>', ']]>', $mystring2);
    	}
    return $content.$mystring1.$mystring2;
    }
    
    add_filter( 'the_content', 'add_contents');

    Can anybody help me see what’s wrong here?

  • The topic ‘How can I append content from another given id in the current post?’ is closed to new replies.