Problems with rewrite rule

I suspect you have a conflict with your query vars. id is already a WordPress query var, and type is a reserved word. You should use vars that you know will be unique among core and any plugin you may use by prefixing everything, like zilvinas_id and zilvinas_type.

Change permalink structure for pagination only

You could filter get_pagenum_link. The parameter has to be paged, not page then. add_filter( ‘get_pagenum_link’, ‘wpse_78546_pagenum_link’ ); function wpse_78546_pagenum_link( $link ) { return preg_replace( ‘~/page/(\d+)/?~’, ‘?paged=\1’, $link ); } But I would rather try to fix the broken rewrite rules.

Default permalink structure causing Notice: Undefined property: WP_Query::$post

Finally I found what causing this problem, turns out it have to do with my pre_get_post hook. Because I using is_page to check the specific page, which is not appropriate. Here is what I did function check_page($wp_query){ if($wp_query->is_page(array(‘1′,’2′,’3’)) ){ //do something here } return $wp_query; } add_action( ‘pre_get_posts’, ‘check_page’ ); So my solution to this … Read more

Don’t change Custom Post Type slug to unique value

you might consider the ‘wp_unique_post_slug’ filter: add_filter( ‘wp_unique_post_slug’,’my_disable_unique_slug’,11,6); function disable_unique_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ){ global $post; if($post->post_type==’cpt’){ // EDIT post type $slug=$original_slug; } return $slug; } This is untested, but you get the idea 😉 ps: you might have to change other things to make this work, since the unique-ness is so … Read more

get_posts post title permalink not working for last item in array

You should use a foreach loop instead, as the count index isn’t the best way to walk over an array. <?php $speakerarray = get_post_meta($post->ID, ‘cpt_food’, true); foreach($speakerarray as $foodname) : $posts = get_posts(array(‘name’ => $foodname, ‘post_type’ => ‘food’)); $post = $posts[0]; echo ‘<a href=”‘ . get_permalink( $post->ID ) . ‘>’ . $foodname . ‘</a><br>’; endforeach; … Read more