indorock
Forum Replies Created
-
Never mind, waiting for an answer here took too long, so I decided to build a custom paging link function from scratch. It’s quick and dirty and might not work for all situations, but it works for mine. So here it is.
A rundown of the function’s arguments:
$format and $link: Work in the same way as the $format and $link arguments in the previous_post_link() and next_post_link() function.
$offset: can be a positive or negative integer, relative to the current post held by the global $post object. So, a value of 1 would give the next post and -1 would give previous one. But any other value will work. If the offset exceeds the range of the set of posts, nothing is returned.
$post_type: self-explanatory. Function is designed to only to query posts of one post type.
$order_by: the name of the field inside your post by which to order your set of posts.
$custom_query_array: An array of arrays of key-value pairs that contains the parameters for the custom query. Same format as when composing a custom meta_query to be passed to the WP_Query object.
Example:
$custom_query = array( array( 'key' => 'teammember_active', 'compare' => '=', 'value' => 'yes' ) ); <div id="nav-above" class="navigation"> <div class="nav-previous"><?php echo get_offset_post_link('%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'powerpuff' ) . '</span> %title', -1, 'tpb_teammember', 'title', $custom_query); ?></div> <div class="nav-next"><?php echo get_offset_post_link('%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'powerpuff' ) . '</span>', 1, 'tpb_teammember', 'title', $custom_query); ?></div> </div><!-- #nav-above -->
Forum: Fixing WordPress
In reply to: "Page not found" for sub-pages of specific slugLet me share my findings with this thread:
I found out the source of the problem was that my custom post type teammember‘s slug as defined in functions.php (i.e. “slug” => “team“) was conflicting with the slug of the subpage I had created (i.e. /team/blabla/). So, I suppose WP’s rewrite functionality cannot handle when it sees a url like /team/blabla/, it doesn’t know if “blabla” is the name of a subpage I manually created under the “team” page, or if it’s the name of an item of custom post type “team”. Apparently it gives the custom post type slug priority over the subpage’s slug, which is why it couldn’t deliver me the subpage blabla and gave me a “Not Found” page instead.
My workaround was to change the custom post type’s slug to be team/member (i.e. ‘slug’ => ‘team/member’) so now I can safely create any number of pages with a slug format of /team/xxxx/ without having to worry about a conflict with my CPT’s slug (just as long as I don’t give my subpage a slug of /team/member/, obviously :P)
HTH others!
Forum: Fixing WordPress
In reply to: "Page not found" for sub-pages of specific slugNicole I have the exact same behaviour as you are describing, weird. The parent page’s title is “The Team” but I want the path to just be “team” so I changed the slug thusly, but that’s when the 404s in all the sub pages started happening. Resetting the slug to “the-team” (default) fixes the issue. But I don’t want “the-team”!