Display custom type posts instead another custom type posts
Question
I develope my WP site so I have 2 custom post types "cases" and "newcases". The "newcases" posts have new design and content. So I have more than 500 "cases" posts and only 20 "newcases".
I need to replace 20 first "cases" with those 20 "newcases" so my permalinks stay as it was (/%category%/%postname%/).
I thought it was simple task and tried like everything(code is below.
Now i get stucked, have you any suggestions?
global $post;
$post_id = $post->ID;
if( $post_id == 27 ) {
$my_query = new WP_Query('p=29');
} else {
$my_query = new WP_Query('p='.$post_id);
}
function custom_pages_services( $query ) {
global $post;
if ( ! is_admin() && $query->is_main_query() ) {
$query->set( 'p', 29 );
return;
}
}
add_action( 'pre_get_posts', 'custom_pages_services', 1 );
0
1 month
0 Answers
43 views
0
Leave an answer
You must login or register to add a new answer .