Friday, February 17, 2023
HomeWordPress Developmentposts - The best way to take away slug from CPT appropriately?

posts – The best way to take away slug from CPT appropriately?


Im making an attempt to take away slug from my Customized Put up Varieties. I’ve added

'rewrite' => array(
    'slug' => "https://wordpress.stackexchange.com/"
)

and based mostly on this submit https://wordpress.stackexchange.com/a/144356/116847 I’ve added:

add_action( 'pre_get_posts', 'wpse_include_my_post_type_in_query' );
perform wpse_include_my_post_type_in_query( $question )  ! isset( $query->question['page'] ) )
          return;

      // Embrace my submit kind within the question
     if ( ! empty( $query->question['name'] ) )
          $query->set( 'post_type', array( 'submit', 'web page', 'physio_methods', 'remedy' ) );
 

 add_action( 'parse_query', 'wpse_parse_query' );
perform wpse_parse_query( $wp_query ) {

    if( get_page_by_path($wp_query->query_vars['name']) ) {
        $wp_query->is_single = false;
        $wp_query->is_page = true;
    }

}

in any other case, posts was combined with pages and will get 404. However now, I’ve downside with posts classes – hyperlink to class show submit, not the archive web page.

I would like to totally take away slug from my CPT. Is there any good (no plugin) answer for that?

Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments