• Resolved kpimarketing

    (@kpimarketing)


    function yasglobal_exclude_post_types( $post_type ) {
      if ( $post_type == 'post' ) {
        return '__true';
      }
      return '__false';
    }
    add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types');

    This code only works with 1 custom post type. I need to disable it from multiple post types – that is for page, post, team,faq, etc.. Using the code two times and change the post type does not work and gives an error, and site goes down.

    I also tried $post_type == ‘post, team’ and $post_type == ‘post’, ‘team’ and they also break the website.

    Is this possible?

    Could you please provide a code example?

    Thank you,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sami Ahmed Siddiqui

    (@sasiddiqui)

    @kpimarketing Here is the code by which you can disable the Custom Permalinks for multiple post types.

    
    function yasglobal_exclude_post_types( $post_type )
    {
        // Add or remove the post types as per your need
        $exclude_post_types = array(
            'page',
            'post',
            'team',
            'faq',
        );
    
        if ( in_array( $post_type, $exclude_post_types ) ) {
            return '__true';
        }
    
        return '__false';
    }
    add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types' );
    

    Let me know if you have any other questions.

    Thanks and Regards,
    Sami

    Thread Starter kpimarketing

    (@kpimarketing)

    Thank you, @sasiddiqui

    I found a work around (see below), but this is perfect and what I was looking for in the first place.

    Thank you very much.

    Work Around:
    *I found that if you reverse the “false” and “true” in the original code that you get opposite results and instead of excluding only 1 post type it includes only 1 post type and excludes all others.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Disable the Custom Permalinks for *Multiple* post types’ is closed to new replies.