Custom sidebar on category pages

one way to accomplish your goal would be to create a child theme (https://codex.wordpress.org/Child_Themes). You create a folder inside /wp-content/themes/, then add a style.css file inside it with a few comment lines at the top to tell WordPress this is a child theme of whatever your current theme is. Sample style.css file: all you need … Read more

How do I get a list of all categories that a given user has written blog posts for?

As, much as I know about WordPress we have to ways to achieve this. First: You have to retrieve all posts written by an author an then you can fetch categories assigned to those posts. Store them in an array uniquely. $args = array(‘author’ => $author->ID, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’); $authorArticles = get_posts($args); … Read more

Get all sub-categories of a parent category

In reply to your updated code, you should know that the $post_terms = wp_get_object_terms() would only return categories that directly attached to the post, so I’d just use wp_list_categories() to get and display the child categories for the given (or a known) parent category. And here’s the code that works well for me which displays … Read more

get_cat_ID() not wokring

get_cat_ID gets the ID of a category based on the name. “Category” is a specific taxonomy named category. You’re trying to get the ID of a Product Category (product_cat). You cannot use get_cat_ID() to get the ID of a custom taxonomy. To do that you need to use get_term_by(): $product_cat = get_term_by( ‘name’, $cat_name, ‘product_cat’ … Read more

What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?

Yes, the post_link_category hook is indeed what you would use to filter the %category% replacement value in the permalink. And here’s an example with prominent_cat being the meta key and the value being the category name (e.g. Pizza Hut), where I’m using get_term_by() to get the category object/data: add_filter( ‘post_link_category’, ‘my_post_link_category’, 10, 3 ); function … Read more

wp_dropdown_categories and custom taxonomy + custom post type

You can get your code to work the expected way by adding the following three arguments to your $args array which you pass to wp_dropdown_categories(): name — the select name as in <select name=”<here>”>, and you should set it to theme which is your custom taxonomy slug. value_field — the value of the <option>‘s in … Read more

List archived posts by subcategory

In your Avada’s child theme update your category.php, if its there or else create new file with that name and add the code as below: <?php $current_cat = get_queried_object(); echo ‘Heading: ‘.$current_cat->name; $subcategories = get_categories( array( ‘parent’ => $current_cat->term_id ) ); if(!empty($subcategories)){ foreach($subcategories as $cat){ echo ‘<br>’.$cat->name.'<br>’; $cat_posts = get_posts( array( ‘posts_per_page’ => -1, ‘category’ … Read more