Articles of categories

Multiple custom post type loops in category.php

I have multiple custom posts types that use the same category taxonomy. Let’s call the CPT’s ‘venue’ and ‘story’, and say we have categorised each of them as ‘foo’. I already have the following code to ensure they’re part of the taxonomy loops: //make sure these custom post types are registered for taxonomy queries add_filter(‘pre_get_posts’, […]

Optimal way to redirect home page to category archive?

Question What’d be an optimal way to redirect the home page of a WordPress site to a category archive without involving external factors (e.g. Apache’s .htaccess) i.e. within WordPress? Why? (Only to justify the question. Please let this not turn the question into too localized.) It’s a news site. The categories are used as Editions, […]

WP_Query arguments to fetch custom post type posts which are in certain category?

I’ve played around for hours but still can’t wrap my head around the right arguments for a secondary WP_Query which shall fetch all posts of my_custom_post_type that are in the queried category. Scenario is a custom category.php template file (writing a custom theme) to render a category archive for custom post type posts. Hence, the […]

403 forbidden on one page only

I can’t access The only error i get is Forbidden You don’t have permission to access /biljke/ on this server. This is regular hierarchical category for post. I have tried: deactivating all plugins (removed category slug also, so url should be but it still redirects me to ). I have deleted htaccess […]

I want to create a posts widget and be able to select categories

Can you please tell me how can I create a wordpress posts widget that outputs posts based on a categories selection ( category checkboxes of all the post categories ) This is in my form function: <?php foreach ( get_categories() as $category ) : ?> <p> <input class=”checkbox” type=”checkbox” id=”” name=”” /> <label for=””><?php echo […]

Programmatically create product category and add thumbnail in woocommerce

I’m trying to create product-(sub)categories on a WordPress installation. The (sub)categories part is no problem at all, but I can’t seem to find a way to add the thumbnail image to the specific category. In wp-admin, the field I want to fill asks for an attachment ID, so I tried uploading the image as attachment, […]

wp_nav_menu not highlighting the current category when viewing a single post

My WordPress site has a bunch of posts, all filed by a top-level category and a bunch of subcategories therein. I have the main site nav rendering the category pages, which, when clicked, get all posts in that top-level category as an ‘archive’. The category highlights as you’d expect when you visit one of these […]

Hide posts of a certain category unless logged in

I want to hide posts belonging to a certain category unless logged in. I found some code(attached) in the codex that works great for the loop. But how to ensure the post pages are empty as well? function exclude_category($query) { if (!is_user_logged_in()) { $query->set(‘cat’, ‘-2’); } } add_action(‘pre_get_posts’, ‘exclude_category’);

Querying Term Posts in Loop

I’m trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine: <?php $cats = get_categories(array(‘taxonomy’ => ‘custtax’, ‘orderby’ => ‘term_group’)); if(!empty($cats)) : foreach($cats as $cat) : ?> <a href=”<?php echo get_category_link($cat->term_id); ?>”><?php echo $cat->name; ?></a> <br /> <?php wp_reset_query(); ?> <?php $cat_posts = […]

Display empty taxonomy terms with get_terms()

I have a function setup as follows: <?php $terms = get_terms(“wpsc_product_category”); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { ?> <li class=”calendar-filter-menu-item” data-filter=”.<?php echo $term->slug; ?>”><?php echo $term->count; ?></li> <?php } } ?> Which displays the taxonomy slug and count for each taxonomy, only problem is […]