Support » Fixing WordPress » Problem with apply_filters function

  • I’ve written a plugin that puts the content of any page or post anywhere I want – like another page or post or a widget

    I’m having problems with the apply_filters function – it messes things up for me

    My code for the plugin is:

    function wp_e_post_function($atts)
    	$post_object = get_post($atts['post']);
    	$myText = $post_object->post_content;
    	$myText = apply_filters('the_content',$myText);
    	return "$myText";
    add_shortcode('wpepost', 'wp_e_post_function');

    The plugin works like this: wherever I put [wpepost post=45], it put the content of page/post with ID 45 in the place

    The plugin works VERY well and perfectly!!!

    ONLY, in some places – like some themes or plugins, there is a problem
    Some of the formatting or functions applied to the rest of the main page content also gets applied

    For example, I’m trying to use an ecommerce plugin
    I’ve got 3 footers where the content of 3 pages is put

    When used with my plugin, the damn shopping basket shows on the footers 🙁

    The problem goes away when I edit out the following line: $myText = apply_filters(‘the_content’,$myText);

    BUT, then the formatting of the page – simple things like automatic paragraphs are missed out!!

    Another example was when I used a twitter plugin, the twitter plugin would also show wherever I used my shortcode to put content from another page

    Where am I going wrong?
    How can I solve my problem?
    Keeping the formatting is really important!

    Is there an alternative to the apply_filters function I can use?

    Any help would be great



  • The topic ‘Problem with apply_filters function’ is closed to new replies.