• Resolved ashf

    (@ashf)


    When I use apply_filters( ‘the_content’, $post->post_content ), div with addtoany_share_save_container class will be added to it regardless of Addtoany’s setting.
    How to prevent this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author micropat

    (@micropat)

    It depends where you’re placing that line and how the post type is setup. For instance, AddToAny won’t appear in blog posts (the post post type) if you uncheck the “Display at the [bottom] of posts” option in AddToAny settings.

    To completely disable automatic placement (and ignore placement options in AddToAny settings), you can remove the placement filters in your functions.php or similar:

    /**
     * Disable AddToAny's automatic placement.
     * Ignore placement options in AddToAny settings.
     */
    function addtoany_disable_placement() {
    	remove_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
    	remove_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
    }
    add_action( 'init', 'addtoany_disable_placement' );
    Thread Starter ashf

    (@ashf)

    I’m using apply_filters( ‘the_content’, $post->post_content ) in a function that outputs custom post type.

    remove_filter( ‘the_content’, ‘A2A_SHARE_SAVE_add_to_content’, 98 ) does not effect AddToAny’s setting?(share button on pages/posts does not go away?)

    Plugin Author micropat

    (@micropat)

    Removing the two filters definitely makes it go away. Check the return values of the remove_filter functions to see if you have it working.

    You might need to experiment with when the filters are removed, i.e. the 'wp_loaded' action hook is fired later than the 'init' action hook. Make sure site caches are cleared, etc.

    • This reply was modified 8 years, 2 months ago by micropat.
    Thread Starter ashf

    (@ashf)

    Actually I’m using apply_filters(‘the_content’) in custom shortcode, but I don’t want to disable AddtoAny whole page.
    i.e. I’ll put shortcode on a page or post so of course I want to use share button outside of shortcode.
    Isn’t there a hook to specify which post type to disable?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘apply_filters( ‘the_content’ problem’ is closed to new replies.