Support » Plugin: ShortCodes UI » Custom Post Type Exclude Issue

  • Resolved ZainB



    Firstly, thanks for creating this plugin. Having migrated from using the Sniplets plugin, it’s great and does a very great job of helping to create re-usable content, quickly and easily. Good work on building a very powerful plugin!

    There is, however, an issue I’m experiencing and wonder if you (or anyone else) can help with? It’s to do with the Shortcodes UI plugin using the “Custom Post Types” functionality to create the shortcodes, which is now causing an issue with another plugin I’m using.

    The shortcodes created are being identified as “Posts/Pages” and the output also contains filtered content from other plugins.

    The plugin I’m using is WP eMember. This plugin has a “Bookmark” feature that identifies Posts/Pages and then adds an icon so a user can bookmark the page.

    The problem is, it is also (correctly) identifying *all* of the shortcodes positions created with Shortcodes UI plugin (since these shortcodes are Custom Posts)! As a consequence, at each point in a page where a Shortcodes UI shortcode is placed, there is also a bookmark icon added.

    I’m Guessing…
    This issue may be caused by the Shortcodes UI plugin using “Custom Post Types”. The content created by the Shortcodes UI plugin is being recognised by this (and maybe other) plugin(s) to be a type of custom Post or Page. When this happens, any filters for Post/Page types get applied as well.

    Question: Is it possible to exclude this plugin from affecting other plugins that actually do need to use Custom Post Types? (i.e. using the data without any filters applied to the shortcode content).

    I think it’s great that you’ve managed to leverage the Custom Post Type functionality to create a very cool plugin. It’s a very clever solution to the problem… However, I’m just wondering if “technically” the plugin is using the Custom Post Type functionality in the right way?

    By this, I mean that it doesn’t create full custom Posts/Pages (as it only uses this feature to store the information easily). The plugin simply makes use of the building blocks provided, but this does seem to be having some very strange side effects… I guess it’s a “Custom Type” but maybe not a “Custom Post Type”.

    What’s the best way of making sure that the plugin isn’t grabbing additional filtered content for Post Types? Any suggestions about how best to exclude this “Post Type” would be very welcome (or grabbing the data *before* any filters are applied, would be cool too!).

    Thanks in advance!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    I think I may have worked out a possible solution…

    Looking at the code in the “shortcode-maker.php” file, it would appear that on line 1229, there is following:

    return apply_filters('the_content',$sc_content);

    What this is doing is applying any filters to the content being pulled out by the SQL statement by $sc_content… which also includes any filters used by other plugins.

    I’ve found that by simply changing this line works, if you just put:

    return $sc_content;

    So, basically, the content being is being pulled out without any filters being applied (just clean data). In theory, I think this would solve the issue with conflicts with other plugins in future.

    Looking a bit further into the code, I’m assuming that the “apply_filters” is probably used so that the “autop_fix” function can be used.

    If this is the case, then surely it would be more appropriate to use just:

    add_filter('the_content' , 'autop_fix');

    I haven’t tested this but, in theory, I think this might work. Basically, it’s applying a specific filter rather than *all* filters to the content.

    As mentioned previously, the Shortcodes UI plugin isn’t really using “Custom Post Types” as they’re intended… but it is having the unintended side effects of filters being applied to “Posts/Pages”. Each shortcode created by the plugin is a “Post Type” and so will naturally inherit any functionality intended for Posts/Pages.

    I hope this makes sense and a fix will be added soon. The Shortcodes UI plugin is a valuable tool, and I’d hate to have to disable it because it conflict with other plugins.



    Plugin Author Bainternet


    Hi Zain,

    Actually the other plugin should give you the ability to exclude or include post types,
    Since this plugin uses custom post types as none public post type (like it should) and the other plugin is just hooked to the the_content filter , And removing the apply_filters('the_content'.... will also remove


    which are the default filters for the content and that will cause some errors in the shortcodes content.

    if you want send over the name of the other plugin and i’ll take a look at it.

    Hi Ohad,

    Thanks, although the plugin is actually a premium one (so I’m not sure about sending it over etc.).

    I appreciate that simply outputting the content without the apply_filters would have an impact to all of the other filters that are being applied to the_content.

    I think I’ve solved it though. I seem to have fixed it by using the remove_filter hook and specifying that the bookmark function used by WP eMember be removed.

    For people experiencing the same issue (with WP eMember and Shortcodes UI), then I hope the following lines of code may help:

    On Line 1229, look for the following:

    return apply_filters('the_content',$sc_content);

    and then change it to:

    $sc_content_filtered = apply_filters('the_content',$sc_content,remove_filter('the_content','bookmark_handler'));
    return $sc_content_filtered;

    Note the part which says: remove_filter(‘the_content’,’bookmark_handler’) – this is the part that will enable all other filters to work, but NOT the “bookmark_handler” filter that’s used by WP eMember.

    As I say, this seems to work for me – smilies etc. all work and the bookmark feature only appears for the page (and not the Shortcode!).



    Plugin Author Bainternet


    a simple solution without editing the plugin and losing changes every update is this:

    function no_bookmarks($content){
    	global $post;
    	if ($post->post_type == 'ba_sh'){
    	return $content;

    Hi Ohad,

    Thanks for taking the time to add this code… I really appreciate it!

    I’ve just tested it by adding this to a plugin (drop-in) I built, although there does seem to be a bit of an issue.

    Testing Strategy:

    1. Add code to plugin.
    2. added echo $post->post_type; after global $post.
    3. Check output of all Shortcode UI shortcodes.

    Result? At this point, the post is returning the Post Type of “page” instead of “ba_sh”, for every instance of a Shortcodes UI shortcode used.

    As a consequence, the bookmarks are still appearing in every shortcode. I’m not quite sure why, so…

    Second Test
    Doing another test on a blog post, I find that the echoed output returns “Post”. So I’m guessing that WordPress is looking at the main Post Type (global $post) for the whole page.

    When rendering the page, the shortcodes created aren’t being recognised as the Post Type “ba_sh”, which is why they can’t be excluded! I have a feeling that this is also where the eMember plugin is failing (as it does contain a newly built exclude functionality for Custom Post Types).

    Note: Changing the filter priority (5) won’t work either, as it’s actually the $post->post_type that needs to be identified.

    The question is: when are the filters being applied? At which point is WP calling the filter? I’m guessing that working out exactly when Shortcodes UI is being called, and what specifically it’s returning is the key to this…

    On Lines 1217 to 1225, there’s the Shortcodes UI database query to bring back the content. At this point, the $sc_content variable isn’t associated to a post or a page – it’s just output “content” (i.e. data to be manipulated and used). There’s NO page/post object for WP to work with yet. Then on line 1229 it’s simply using the apply_filters on this data.

    What’s being returned? I’m guessing that it’s just data with no specific Post Type.

    Not quite sure how best to proceed with this… For the moment, I’ll use the remove_filter code, until a more appropriate solution appears.

    I have to say, this is quite an interesting and challenging issue. I’m learning quite a bit from this… 😉

    I hope that helps a bit more. If I find anything else out, I’ll let you know…



    Thinking about it… I’m also wondering why the bookmarks are appearing if the Custom Post Type isn’t being recognised!?!

    What’s happening at the point of the filters? On the one hand, WordPress isn’t seeing the “ba_sh” post type, but on the other hand, it is!

    (Anyone else want to add to this? I lay down the gauntlet for any challengers to this issue..! 😀 )

    Plugin Author Bainternet


    You are correct that will never work, So i pushed an update with tow action hooks just for you.

    DO NOT edit the plugin or paste anything in it!!! the whole idea is to still enjoy the updates so paste this in your theme’s functions.php or a custom plugin:

    //this is to remove
    function no_bookmarks($content){
    //this return the bookmarks if needed down the road
    function return_bookmarks($content){

    Once you update to 1.8.8 paste this code (all of it) in the theme’s functions.php or a custom plugin:

    Hi Ohad,

    Thanks for this update. I’ve just tested version 1.8.8 and it seems to work just fine. The only thing was to remember to save the settings for the shortcodes to re-appear (otherwise, they seem to disappear!).

    I’ve now put the first code (i.e. remove) into my drop-in, and the filters for the shortcodes (like smileys) are working. I can also confirm that the bookmark icons have also been removed. Woohoo! Good job!

    Testing the return function… I’m not sure but I can’t seem to get it to work and return the bookmarks. (Then again, it’s not really important for what I’m doing!).

    Looking at the code… the new action hook is pretty smart, and very powerful too! I can see how just adding that will also help if anyone ever needs to remove a particular filter from the SCUI plugin.

    Anyway, I really appreciate your help with this issue. It’s now definitely on my list of plugins I can recommend to people!


    PS: …And yes, it is better to allow plugins to update without needing to tweak them. I completely agree, which is why I have my own drop-in for essential site tweaks! 😀

    Hi Ohad… just to let you know, I tried sending you a donation via PayPal but your site is broken!

    I then tried contacting you using your contact form… and that’s borked too! The contact form keeps saying: “Are you sure you want to do this?” with no yes/no buttons… (the browser title of the page is WordPress Failure Notice, btw).


    Anyway, I hope you get *this* message!



Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Post Type Exclude Issue’ is closed to new replies.