Changing category base slug results in 404 errors on posts?
Changing category base slug results in 404 errors on posts?
Changing category base slug results in 404 errors on posts?
When I refresh the error page, it just refreshes. If the rule has been put in the correct place in the .htaccess file (ie. near the top of the file before the existing WordPress code block) then you shouldn’t be seeing an “error page” at all (if the redirect occurred correctly). (If you place this … Read more
When using get_terms with hide_empty = true, terms that only contain scheduled posts are not returned. How to override this?
You need to first store your sub category id and pass that to WP_Query. Below is the logic how we can store the child category value. $categories = get_the_category(); // store the subcategory id $sub_category_id = []; foreach($categories as $category) { if( $category->parent > 0 ) { $sub_category_id[] = $category->term_id; } } $args = array( … Read more
That title is coming from archive.php file of TwentySixteen theme. You can find a <header> code section in that file. What you can do, simply copy the archive.php file as category.php and then remove the following code section from category.php file: <header class=”page-header”> <?php the_archive_title( ‘<h1 class=”page-title”>’, ‘</h1>’ ); the_archive_description( ‘<div class=”taxonomy-description”>’, ‘</div>’ ); ?> … Read more
OK, found it. it is possible to have the same slug for a page and a category name. The problem was that someone installed a “redirection” plugin that caused the problems. Lesson learned is to restrict the capabilities of people working on the website, so that they cannot install plugins..
All the items under your “What I want” list can be easily achieved using the Posts List block which is a variation of the Query Loop block, and if you want to, you can create your very own variation – see Extending the Query Loop block in the block editor handbook. You can check the … Read more
get_the_category() has a filter, get_the_categories, that will filter the categories. You can do something like this: add_filter( ‘get_the_categories’, ‘wpse426499_filter_categories’ ); /** * Filters the categories. * * @param WP_Term[] $categories An array of WP_Term (ie, category) objects. * @return WP_Term[] The filtered array of WP_Term objects. */ function wpse426499_filter_categories( $categories ) { $undesired_id = 2; … Read more
How to make query loop block dynamic
To directly answer your question, you can use the wp_setup_nav_menu_item filter to change properties of the nav menu item: add_filter( ‘wp_setup_nav_menu_item’, static function ( $menu_item ) { if ( ! is_admin() || empty( $menu_item->taxonomy ) || ‘category’ !== $menu_item->taxonomy ) { return $menu_item; } $menu_item->title .= sprintf( ‘ (%s)’, $menu_item->slug ); return $menu_item; } ); … Read more