Add below code into functions.php file
function change_slug_struct( $query ) {
if ( is_single() ) {
// If you want pass all custom post types array dynamically then use below code
$get_cpt_args = array('public' => true, '_builtin' => false);
$post_types = get_post_types( $get_cpt_args, 'object' );
// do something with array
$post_type_array = array();
if ( $post_types ) {
foreach ( $post_types as $cpt_key => $cpt_val ) {
array_push($post_type_array, $cpt_key);
}
}
//That's it
if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
return;
}
if ( ! empty( $query->query['name'] ) ) {
// Option 1 - specific CPT passed here
$query->set( 'post_type', array( 'custom_post_type1, 'custom_post_type2', 'single-link', 'page' ) );
// Option 2 - all CPT passed here dynamically
$query->set( 'post_type', array( $post_type_array ) );
} elseif ( ! empty( $query->query['pagename'] ) && false === strpos( $query->query['pagename'], '/' ) ) {
// Option 1 - specific CPT passed here
$query->set( 'post_type', array( 'custom_post_type1, 'custom_post_type2', 'single-link', 'page' ) );
// Option 2 - all CPT passed here dynamically
$query->set( 'post_type', array( $post_type_array ) );
// We also need to set the name query var since redirect_guess_404_permalink() relies on it.
$query->set( 'name', $query->query['pagename'] );
}
}
}
add_action( 'pre_get_posts', 'change_slug_struct' );
Your ideas absolutely shows this site could easily be one of the bests in its niche. Drop by my website QU6 for some fresh takes about Cosmetics. Also, I look forward to your new updates.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Get ready to elevate your betting experience with an exclusive 1xBet promo code! Whether you’re from Bangladesh, Pakistan, India, Nepal, Sri Lanka, Nigeria, Egypt, or the Philippines, you can unlock amazing rewards like free bets, no deposit bonuses, and free spins using the latest 1xBet promo codes today. New users can enjoy a special registration promo code that boosts your first deposit or even gives you a chance to play risk-free. Looking for a Bangladesh 1xBet promo code or a 1xBet promo code India for the app? We’ve got it all here, updated daily. Don’t miss your chance to grab a 1xBet official promo code, win big, and make the most out of your betting journey. Claim your 1xBet free promo code today and start winning smarter with bigger bonuses, free spins, and more exclusive offers worldwide! No matter where you are, finding the right 1xBet promo code today means unlocking bigger chances to win, with offers perfectly tailored for players across Bangladesh, Pakistan, India, Nepal, Sri Lanka, Nigeria, Egypt, and the Philippines.
After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.