robmarston
Forum Replies Created
-
Forum: Reviews
In reply to: [Tag Selector] Very helpful but not "idiot-proof"@nick6352683 thanks for the great feedback. While I don’t want to explicitly disable the plugin’s use on custom post types I would love to give the user the option to select which types of posts the meta box is available for. As a developer would you prefer this type of customization on it’s own settings page or within the metabox itself? Thanks again!
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@evanherman it does, I even tried hard-coding it to 2 and testing the second page URL — same result. The strange thing is, the next pagination link shows up on page 1 so it’s definitely realizing there’s a second post that’s available to be shown.
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@evanherman as of PHP 5.4 (I believe) you can use bracket syntax for arrays. I did try reverting it just in case but it had no affect. Good suggestion though!
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@evanherman agreed. My code was heavily customized so I figured it wouldn’t do anyone any good to have to sift through it but I definitely agree it’s much easier to help diagnose the issue(s) if you have something to look at. I’ve included some simplified versions of both queries below in case someone experiencing the same issue stumbles upon this post. Cat was replaced with tag if the archive was for tags. Here’s a summary of the issue:
– Page 1+ of the review (CPT) archive worked as expected (used archive.php).
– Page 1 of the category/tag archive worked, showed correct pagination (used archive.php).
– Page 2+ of a category/tag archive redirected to the 404 template (used archive.php).Original code:
archive.php $args = [ 'cat' => $category, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'posts_per_page' => 1, 'post_type' => 'review' ]; query_posts($args); if (have_posts()) : while (have_posts()) : the_post(); ...
Revised code:
archive.php if (have_posts()) : while (have_posts()) : the_post(); ... functions.php function add_custom_types($query) { if (is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) { $query->set('post_type',[ 'post', 'nav_menu_item', 'review' ]); return $query; } } add_filter('pre_get_posts','add_custom_types');
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@girlieworks reverting my custom query_posts call back to the standard loop fixed it. It must’ve been something to do with execution order, resetting the main query, etc. I had to add a filter to my functions.php file to set post_type to my custom post type but all is working as expected now. As others have previous mentioned, taking advantage of the query already in motion is always better than writing your own … some have even gone so far as to say “Don’t use query_posts!” lol. Anyway, not sure exactly what the root cause was but it’s solved now nonetheless ??
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@girlieworks interesting, I hadn’t seen that done before. I tried it and sadly it did not work. With a period in the category base field I now get a 404 at https://example.com/action in addition to https://example.com/category/action. I’m going to try create separate category and tag templates using the standard WP loop and see if that helps, I have a sneaking suspicion the query may be the issue. I’ll respond with my findings shortly, as always thank you for your help!
Forum: Fixing WordPress
In reply to: 404 error on tag/category archive page 2@girlieworks thanks for the suggestion, I didn’t think to change the bases back … I just tried it however and the same issue still occurs. I forgot to mention in my original post that I’ve flushed the rewrite rules/permalinks several times to no avail. Curious if that 4-segment URL structure is supposed to work out-of-the-box? This one’s a real head-scratcher.