Support » Plugin: Post Type Switcher » Advanced filtering (restrict to specific CPT)

  • Hello,
    I’m building the intranet for my company and we ended up having a huge portal. One of the options is for the employees to submit News items from the frontend. When they submit it, the entry is set as a draft in the “news” post type. We also have a blog section, which uses the normal posts (CPT ‘post’). Well, since some submited news item might go better into the blog section, I opted to use a plugin that makes it easy for the administrators of the move them in the blog, thus Post Type Switcher.

    The problem that I’m having is, I want to restrict the functionality of the plugin to just ‘news’ and ‘post’, and not have it displayed on other post types (we have many), and restrict the ability to switch only between news and posts.

    I ended up using this code and a jQuery to hide the option from the quickedit box:

    add_filter( 'pts_post_type_filter', 'pts_disable');
    function pts_disable( $args ) {
    $postType = get_post_type();
    if( 'post' === $postType ) :
    $args = array(
    'name' => 'news'
    elseif ( 'news' == $postType ) :
    $args = array (
    'name' => 'post'
    else :
    $args = array (
    'name' => 'none'
    return $args;

    Basically, this code is crap. When editing a news type, after updating, it moves the news to posts by default. There isn’t a lot of documentations of about this filter, so I don’t know how to achieve everything that I want. Currently, I removed the function and just flooded the backend .js with jQuery functions to hide everything that isn’t “news” or “post”, and hide the quickedit option to any post types that aren’t ‘news’ or ‘post’. This option works, of course, but it’s very nasty and would prefer something default.

    Can you guys help me out and try to figure out if I can do everthing with pts_post_type_filter?

    Also, johnjamesjacoby > yoast 🙂
    Have a great one guys

Viewing 1 replies (of 1 total)
  • This is how I ‘fixed’ it with jQuery (added backend script):

    jQuery('.inline-edit-row #pts_post_type').parents('.inline-edit-col-right').hide();

    jQuery('#pts_post_type option').each(function(){
    var _post_type = jQuery('#post_type');
    if(jQuery(this).val() !== 'news' && jQuery(this).val() !== 'post') {

    if(_post_type.val() !== 'news' && _post_type.val() !== 'post') {

Viewing 1 replies (of 1 total)
  • The topic ‘Advanced filtering (restrict to specific CPT)’ is closed to new replies.