Questions tagged [categories]

Every Post in WordPress is filed under one or more Categories. Categories allow the classification of your Posts into groups and subgroups, thereby aiding viewers in the navigation and use of your site.

1,248 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
2answers
1k views

Filtering a custom post type by custom taxonomy in archive template

I've seen this question posted in different forms before, but most of those solutions are centered around the admin interface, and I haven't found any answers that apply to the front end. I've got a ...
4
votes
1answer
840 views

Add category to custom post URL

I am trying to create custom post with custom taxonomy and categories. Structure is like: Product: Has categories Has taxonomy Custom post type create: function create_alco_custom_post() { $...
4
votes
1answer
792 views

Custom Nav Walker menu - Display category count

I have a custom walker menu.( See the code below) I would like to have my nav menu like this: Where 495 is the total of the records containing childrens. Where 42 Number of published articles. Can ...
4
votes
1answer
162 views

Get page content by category or tag

I'm trying to sort of emulate the Views behaviour in Drupal with WordPress, but doing it in theme templates. Now, I have pages that are assembled by using wp_query in the template to get posts ...
4
votes
1answer
322 views

How to sort posts by last name (2nd word) on ONE category only?

I have an "author" category that is used as a list to browse multiple posts containing author biographies. I have Smart Category Ordering installed and right now it is sorted by title ascending. ...
4
votes
2answers
4k views

Display all posts from all categories with pagination

Alright, this might be a tricky one to explain but I'll do my best. At the front page I want to display all the posts from all the categories. However I want them to be divided. Take this for an ...
3
votes
1answer
131 views

Count argument in get_terms has no effect on ouput/doesn't work

I'm trying to get a count of the categories that are subcategories of a category with the id $categoryId. In the documentation for the term query object, which is the primary argument to get_terms, ...
3
votes
1answer
43 views

How do I get the total number of categories in a list of search results?

I want to display the total count of categories in a set of search results. For example, "10 posts found in 3 categories." (Assuming that each post has only 1 category.) Right now, my solution is to ...
3
votes
2answers
2k views

List of subcategories with featured image

In a page, I need to display a list of all sub categories of a specify category. For example, in the category Sport have 6 subcategories: Swim Football Basket Ski Hockey Each ...
3
votes
1answer
341 views

WordPress previous_post_link exclude posts with multiple categories

I have a single-news page in WordPress where I am looping over all the posts and conditionally updating the previous and next buttons to exclude certain categories based on the current post's category ...
3
votes
0answers
47 views

Render Selected Categories in Admin Edit Post Screen differently

Selected Categories for a post in the admin screen are rendered by: // Put checked cats on top $output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); ...
3
votes
0answers
99 views

get / list categories and counts filtered by custom taxonomy term

In my post 'post type' besides "categories" I've a custom taxonomy called "product-types". The category is actually more "manufactures" of the product types. I've a product-types page where I list ...
3
votes
0answers
50 views

How to show custom taxonomy in the permalink?

I used the Portfolio Post Type Plugin to create custom tax and post type. I would like to show the custom taxonomy on the portfolio projects. portfolio/customtaxonomy/project while now is ...
3
votes
1answer
67 views

Is it possible to put tags and category information in the post as text?

Is it possible to put tags and category information in the post area, so one doesn't have to click the appropriate fields and use the mouse? Ideally I just want to type "#art" "cat:painting" in the ...
3
votes
1answer
158 views

Action hooks returning old category instead of new category

With some help I created a WP Action to send an email to the author of a post (custom post type) when the category has been changed. This works ok, except that the function is returning the previous ...
3
votes
0answers
328 views

Add custom field to category of custom post type

I want to add a custom field (for a icon) to categories of a custom post type. I use the default category type and not a own create category taxonomy. How can I add the custom field only to the ...
3
votes
0answers
121 views

Category checkboxes in upload modal

In a project I'm working on, I've enabled categories for attachments using: register_taxonomy_for_object_type('category', 'attachment'); In the edit attachment screen in the Media Library you see ...
3
votes
1answer
163 views

Plural Category Base Slug On Category Archive Page

I've got a little problem with the category base slugs. Say I have got a category called 'Resources', with the category slug set to 'resource'. So any post in the category resource will appear with ...
3
votes
2answers
2k views

Wordpress Child Category Display All Posts

I am creating a Wordpress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it ...
3
votes
0answers
412 views

Post in Multiple Categories to stay in current category (permalink, next previous post link)

I guess this has been mentioned before, but after 2 days of browsing i haven't find a complete solution. Maybe someone has come across this problem before? I'm building a designer portfolio where ...
3
votes
2answers
721 views

custom permalinks for category archive ( custom base and no parent slug )

For the default taxonomy i.e category , I want custom permalinks with i) base = "post/c" and ii) without any parent slug For eg: if I have categories cat-a subcat-a1 subcat-a2 cat-b ...
3
votes
3answers
11k views

404 Error On Category and Tags Pages

Okay So I'm facing a weird problem as i'm receiving 404 errors on blog category and tag pages. I'm using custom theme which includes: tag.php category.php archive.php home.php index.php and 404....
2
votes
0answers
147 views

Embed YouTube video on category description

I would like to embed a YouTube video on my category description pages. When I pasted the URL or embed code in the editor, I see the video. But on the page itself it just shows the code. Is there a ...
2
votes
2answers
556 views

Add Category name to Post Title (h1)

How to add Category name to post title (H1)? “PostTitle + CategoryName”? My h1 post title code: <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
2
votes
0answers
98 views

Custom Category/Subcategory structure

I am building a site with several sections, and one of them is a special page to navigate through categories in a hierarchical style (you can navigate into categories/subcategories and see their ...
2
votes
1answer
104 views

Category archive page - loop through posts of certain tag (with pagination) - pre_get_posts

I have a category archive page (press), which I need to loop through posts of a certain tag (magazines). I tried to modify the query with pre_get_posts, but it is still just showing posts in the '...
2
votes
0answers
226 views

display most popular tags of category?

0ne year ago i used this code to show most popular tag of the current category in my sidebar: function my_tags_from_category( $atts, $content = null ) { extract(shortcode_atts(array( 'type' => ...
2
votes
0answers
116 views

Wordpress menu that shows all posts in a certain category like w3schools

I am working on creating a widget menu(kind of a sidebar like w3schools) that is supposed to show all posts that are listed in a particular category. And update automatically from particular category(...
2
votes
1answer
481 views

How to display related posts from parent category

I am using the following code to display the related posts but it is showing posts for that category only like brand showing brand posts only. What I am looking for is if I select any of the posts ...
2
votes
1answer
239 views

Conditional that checks if a current category has any subcategory with posts

I'm looking for a way to make a conditional rule that checks, in a category archive template, if the current category has any subcategories with posts. More specifically, the posts are "products" in ...
2
votes
1answer
1k views

How to search only by post title and category?

I'm currently working on my first theme (based on underscores) and just realized the search does not return any results if I input a category name, nor does it give accurate results when searching ...
2
votes
1answer
3k views

Remove Parent Category from Child Category URL

I am trying to remove parent category from the child category but each attempt returns a 404 error. Main Category Link (Displays All India Recruitment) Child Category Link (Displays Sub-Category) ...
2
votes
1answer
301 views

Add custom taxonomy under the category title

I've added a custom taxonomy to my product category page in the admin. I can call the custom field using the following: $queried_object = get_queried_object(); $t_id = $queried_object->term_id; $...
2
votes
0answers
736 views

Custom Loop through category menu to include sub categories

In my custom wordpress theme I currently have the below loop to the main categories <?php $menu = wp_get_nav_menu_object('navigation'); $items = wp_get_nav_menu_items($menu->term_id); foreach($...
2
votes
0answers
1k views

Category page shows Oops! That page can’t be found

The article categories can't show the articles. It appears the error message "Oops! That page can’t be found." How do I fix it?
2
votes
0answers
117 views

wp_list_categories

I wonder if anyone could shed some light for me. I have updated wordpress and one of my plugins has stopped working, which is also up to date. I have narrowed it down to exactly what isnt working the ...
2
votes
1answer
1k views

Custom HTML structure in wp_list_categories

I am trying to accomplish an Ajax navigation for the categories and for that I need the code to look something like: <ul> <li data-level="1">Parent Category</li> <li data-...
2
votes
1answer
193 views

Get the category is not working on url

Although this is my first post but i have been coming here for answers so I know the rule and this isn't a duplicate because i have tried whatever i could but couldn't seem to get my codes to work. ...
2
votes
0answers
211 views

Divide Loop Into Days & Categories

If you could help, I'd greatly appreciate it, because I'm halfway there, but I'm currently stuck! The site I'm working on needs to have it's posts, within the loop, divided up by days, and then under ...
2
votes
1answer
179 views

CPT posts listed by category with custom rewrite URL, please help!

Here is what I'm trying to do: I have 10 total dessert recipes (in shared dessert category) that are divided by 2 custom post types. I want to create 3 different views of these posts with the custom ...
2
votes
0answers
3k views

Posts are not showing up on particular category

On my website, post are not showing up when I navigate to http://www.domain.com/category/category-name/ but on wordpress dashboard, I am able to see the actual number of post under that category. ...
2
votes
0answers
554 views

One WP install, I need to map a custom domain name to each category

I've read other answers but they weren't satisfactory. Multiple blogs, different domain names, one install to rule them all Multiple Domain Names - One WP Install (non-Multisite) - Default Each ...
2
votes
2answers
101 views

How to show in search results posts with a particular tag in a particular category?

As the home page of my blog I've a static page. There I want to show the navigation of the site. Category1 Sub-Category1 tag1, tag2, tag3 Category1 Sub-Category2 tag1, tag2, tag3 Category2 Sub-...
2
votes
2answers
959 views

Multiple post categories - single permalink

I created a post which is assigned to multiple categories. Eg: I have a post "My Post", and I put it in "foo" and "bar" categories. Now my article will have two permalinks, "/foo/my-post" and "/bar/...
2
votes
1answer
83 views

Category vs Tag vs Table

I have a site that will hold roughly 1000 posts/articles from an in-house magazine dealing with Australian naval history. The articles cover a range of subjects (such as Aviation, Intelligence, Ship ...
2
votes
1answer
616 views

How can I get archives for specific category without category_base in the url?

I'm using this code to get archives for a specific category: function extend_date_archives_add_rewrite_rules($wp_rewrite){ $rules = array(); $structures = array( $wp_rewrite->...
2
votes
1answer
140 views

How can I list random authors from current post category?

The following lists authors of the current category. But I want this to be a list of 6 random authors from current post category. foreach((get_the_category()) as $category) { $postcat= $category-&...
2
votes
1answer
111 views

How to prevent empty category to list content of sub categories?

I have a category structure like following: A ->B ->C D (B is sub category of A and C is sub category of B) I have content only for category "C" and if I open Category "B" the content of ...
2
votes
4answers
2k views

How to disable Uncategorized category URL?

I would like to disable the Uncategorized public URL (i.e. /category/uncategorized), since I'm not using post categories and already have the posts list with pagination on the main Blog posts page. ...
2
votes
1answer
1k views

Add category to all post by using sql query?

I have a thousand posts and all them don't have category. Do you know how to associate category with all posts by using sql query?