Dynamically display sub-categories on primary menu without adding them
Another user has provided sample code in a separate thread. Reading their code, it appears to be just what you’re looking for. Good luck!
Another user has provided sample code in a separate thread. Reading their code, it appears to be just what you’re looking for. Good luck!
Function add class to second menu specific items if the page has a certain category
This issue occurred in WordPress core development. they give me answer on below ticket thread Date: Thu, 12 Sep 2019 15:36:49 -0400 Subject: [PATCH 1/2] Added special character decode to menu item title src/wp-includes/nav-menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff –git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index f130d2f3e1..db8a2fcf78 100644 find this code on … Read more
The function you are using here, get_post() does not accept query arguments. So you have to use get_posts(). Try this: $latest_post = get_posts( array( ‘cat’ => 3, ‘posts_per_page’ => 1) ); if( !empty( $latest_post ) ) { echo ‘<a href= “‘ . get_permalink( $latest_post[0] ) . ‘”>Learn More Now</a>’; }
Have you tried the classic debugging process? (It is better to perform these operations on a local environment rather than on the production environment) Make a full backup of your website Try to disable the plugin one by one and see if the bug disappears. Try to change the theme You can then identify if … Read more
Your question is not very understandable…. I’ve never used this plugin, like most people here. It’s hard for us to help you, I think your question is too specific and you should contact the author of the plugin. If you find the solution to your problem, don’t hesitate to publish it here in response, it … Read more
Using query_posts is asking for trouble, because its results may be unpredictable (read more about that in this post). In stead you should define a new query and loop through its results. Like this: $args = array( ‘category_name’ => ‘news’, ‘posts_per_page’ => ‘3’ ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { … Read more
Confusingly, get_the_category() returns an array of categories, so you’re going to need to loop through them. It sounds like you want whichever category is assigned to the current post, and is also a sub-category of category id 11. If that’s the case, use <?php // Get all the categories assigned to this post $categories = … Read more
Get_term_meta() always returns false
I finally, finally figured it out! I was not able to get the category id in the first place. Strangely, get_query_var(‘cat’) is not working. Here is the way that worked for me, in case someone else also struggles with this: function my_new_category_order( $query ) { $category = get_queried_object(); $cat_id = $category->term_id; $post_order = get_term_meta($cat_id, ‘post-order’, … Read more