Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [get-categories]

Returns an array of category objects matching the query parameters. Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax.

0
votes
0answers
15 views

Show categories not in gallery post format

I want to show all blog categories that aren't of type gallery. My code almost works but if I have 2 posts in the same category the category is shown twice ie: If I create a category called 'news' ...
0
votes
2answers
17 views

Custom post type category not displaying category ID

I'm trying to get the category ID so I can call a loop query on only that category ID. However the following code returns null. Any ideas why? In the admin bar it shows edit category with an ID of 3, ...
0
votes
1answer
16 views

Retrieving Categories based on the first character of the name

I was wondering how I can get information from the wp_list_categories object just using the first character of the category name. For example, I want to get the listing of categories based on the ...
0
votes
1answer
24 views

Custom Post Type Categories URL not displaying posts

I'm not as good as many wordpress developers here and I hope someone can help me, I've created a Custom post types for hotel destinations with categories for country and city. When I go to mysite.com/...
0
votes
0answers
18 views

can i add admin menu for set query category id?

I am thinking of something.that i want to add a wordpress admin menu for set category id. i mean i designed news section that lists post from specific category. like this: Sports News Post from ...
0
votes
1answer
22 views

How to retrieve category of a post in have_post loop?

I am using a CPT (post_type => 'portfolio_type', taxonomy => 'portfolio_cat'). Under this CPT, I have design, web development category. I am trying to get the post with the category. My best try, ...
0
votes
0answers
15 views

How to list all categories a post is in, but exclude current post´s category on single post page

I´d like to list all categories (links) a post is in, like when I use "the_category()", but need to exclude the current category. Ex: Post name is "Bob Marley´s songs", published in the categories "...
0
votes
1answer
25 views

How to get featured image of last post in a category?

I have the following code and want to add a selected featured image $arg = array( 'orderby' => 'date', 'number' => 10, ); $categories = get_categories($arg); ...
0
votes
1answer
12 views

Get only children category name

On a single post, I display the post's categories like this: $categories = get_the_category($id); My category hierarchy is: cat1 parent of cat2, parent of cat3, etc. I would like to display only ...
0
votes
0answers
9 views

How to get post categories before publish/update post?

Im trying to get the post category before it be published, it is possible? Because I need to check some things before publish at all. public function __construct() { add_filter( '...
0
votes
1answer
19 views

Is there a way to fetch the category of a page when using wp_list_pages?

Currently we’re using wp_list_pages to show a list of child pages. However, we’d like to get the category of each page, and display some CSS on the front-end based on what category each page is in. ...
0
votes
0answers
14 views

Wordpress - Get 2nd level child categories while looping 1st level child categories

I'm trying to loop and get the 1st and 2nd depth child categories of the 'Parent Cat 3' which has the id of '17'. Here's a simplified form of my category structure PARENT CAT 1 PARENT CAT 2 PARENT ...
3
votes
1answer
52 views

Alphabetical Index Page

I can't quite seem to wrap my head around the logic needed to create an Alphabetical Index page. I can get a rudimentary version working but what I'm trying to do is create something like this https://...
0
votes
1answer
32 views

Deleted categories still listed until additional page refresh

I've tried using wp_delete_category() and wp_delete_term() to delete a category, but after the page reloads, the deleted category still shows up in the results of get_categories(). But if I reload the ...
0
votes
1answer
22 views

How to call Primary Category for WordPress Woocommerce

I have try for several hours to solve this but I am getting nowhere. In the class-wc-structured-data I would like to add a Markup for "brand" as on my website the brand = the parent category $markup[...
0
votes
1answer
19 views

How can I display categories on different pages

I am working on a theme. Woocommerce categories are displayed on home page but I need to add on shop page, product page and category page. How can I do this.
0
votes
0answers
17 views

List of categories, sub-cat and posts as links

I have a site with over 10,000 articles and categories. I would like users to navigate the following way. A page will have a list of links with top level categories: - Category 1 - Category 2 - ...
1
vote
1answer
29 views

Custom post type, organized by categories

I know there are lots of questions and answers out there for this very thing, but I'm having a hard time putting it all together. The goal is to get a <ul> with category names as the <li>, ...
0
votes
1answer
34 views

How to order get_categories() in the same order as the menu?

I'm using a theme and I noticed that it dynamically displays an array of the categories in the menu: I need the same list of categories but within different HTML tags for my footer. Currently this is ...
0
votes
0answers
109 views

How to display values of multiple checkboxes in WordPress

I have a page, on the page i show my site categories in the form of checkbox.and user can select multi category When user select multi category i can save that in database but can't show selected ...
0
votes
0answers
17 views

Call category by brands on brand detail page woocommerce

Can i call category by brand? I want to show category listing instead of products at brand detail page i am using Perfect WooCommerce Brands for my site kindly somebody can help i am new in ...
0
votes
1answer
31 views

How can I create a Category Index page that lists all categories?

I have themed my category.php file so it now displays all posts that belong to the category that was clicked. The URL looks like [www.example.com/category/news/]. This is good and correct. When I go ...
2
votes
2answers
56 views

Problems with function on function.php

I've a problem with some functions on function.php. I want to use get_tems_by("slug", $slug, "category"); but it doesn't work inside a function on function.php. When i changed slug by ID and give a ...
-1
votes
0answers
13 views

Echo the first category out of an assigned categories array

I have a lot of posts that I need to assign in multiple categories, usually two but sometimes more than two. The assigned categories is a mix of parent/parent and parent/child but never a child/child ...
1
vote
1answer
31 views

How would I go about pulling the most popular (most used) categories?

I am trying to use WordPress' built in function for calling a list of categories. Unfortunately there doesn't appear to be an argument for how to pull the most popular categories (say top 5). I am ...
1
vote
1answer
21 views

Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?

Objective: When a category is clicked I would like the category.php page to dynamically pull in all posts filed under that clicked category. Example: News -> (Action:Click) -> Category = News ...
0
votes
0answers
23 views

Get an array of all the categories and sub-categories of a custom taxonomy

I have a custom post type "apis". This post type has a custom taxonomy "api_category" which has categories and subcategories. What I need to do is get an array of all the categories in this custom ...
0
votes
1answer
16 views

How to show some of category in wordpress

I listed all category in front page with get_categories() function But i dont want show all category in output For example i dont want show catgegory with id=25 How to should i do that? This is my ...
2
votes
1answer
36 views

get deepest Woocommerce Product Category on Archivepage

I use Woocommerce in my theme and was wondering how to get the unique category, when checking terms. what I did so far: I enabled the theme supprt add_theme_support( 'woocommerce' ); in the ...
1
vote
1answer
648 views

get_the_category() always returns empty array

Let me explain my situation, I have left menu and menu name is a category slug. Now I want to add next and previous button at the bottom of every post which refer the next and previous menu item. here ...
0
votes
1answer
18 views

How to get the categories of a selected blog on multisite?

I trying get the categories in a function from a selected blog on my multisite with switch_to_blog, but I get the categories of the current blog, and I dont understand, why... I searched the solution ...
0
votes
1answer
31 views

Make/create a category for every page

I'm trying to make it so there's a category that matches every page (excluding a couple). So if I have the pages as such: Pages |-- Ninja Turtles | |--Turtles | | |--Raphael | | ...
3
votes
1answer
68 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, ...
0
votes
2answers
76 views

Custom Category widget

I have a custom code in sidebar.php that shows all my categories and number of posts+custom posts. The code is working fine but, since I copied/pasted and modified various other codes from ...
0
votes
1answer
439 views

Display 3 levels of categories on page

I have a loop that takes the cat_id of the top-level e.g. "Data", loop through the categories, display the second level as H2s, and then display the posts in each subcategory. Data Analytics ...
0
votes
1answer
100 views

Dropdown menu for subcategories

This code shows all categories available and also the subcategories beautiful listed right below its suitable parent category. Is it possible to make a nested menu, so that when I click on the parent ...
0
votes
2answers
60 views

Show posts from categories instead of tags

I am trying to change this wordpress function given in my theme to show posts from category instead of tags. But due to wordpress beginner i am unable to do this. Please help me to change this code....
3
votes
1answer
134 views

How can i list custom post type categories?

I have a custom post type called "us_portfolio". And i do have portfolio categories for each of my product type. What i need is listing the portfolio categories in my home page. I am not expert so ...
-1
votes
1answer
344 views

WP Archive & Category Pages not filtering

I'm going bananas. I'm creating custom archive pages for a client because whoever originally developed their site didn't create any. I've got the pages there and working like they should, but it's ...
0
votes
2answers
669 views

Only show categories that have posts within custom post type

My custom post type & built in Wordpress blog posts SHARE the built in categories. I have a piece of code that loops through and shows all (built in) categories that have posts assigned to them ...
0
votes
1answer
207 views

Display custom taxonomy on single post

I have 4 different custom entries from my custom category. Categories are: john-doe, jane-doe, john-does, jane-does Each of the user have different posts. Let's say John Doe have a post, but on that ...
0
votes
3answers
357 views

How to display child categories of all parent category within a singe loop?

$args = array( 'post_type' => 'listing', 'order' => 'ASC', 'hide_empty' => false, 'parent' => 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( ...
0
votes
3answers
116 views

Do not want to display random category. Want to exclude a few or make post show only the category I want [closed]

I'm stuck in a strange situation right now. So I have my wordpress posts which belong to multiple categories. e.g one of my post belongs to two categories. One is 'News' category, and the other one is ...
0
votes
1answer
188 views

What does 'category__in' mean in queries?

Can someone please help me understand what does the following statements mean? Specifically array($category->term_id)? 'category__in' => array($category->term_id) Does that mean this ...
0
votes
1answer
43 views

With wp_list_category put every existing category into an option tag

Like the title says, I'm using wp_list_categories to get all of the existing categories of my website listed. I would like to achieve this: <select class="filters-select"> <option value="....
0
votes
1answer
229 views

get full category structure by post id

I have three level category structure as bellow. - parent 1 - parent sub 1 - child 1 - child 2 - parent sub 2 - child 3 - child 4 Unfortunately, some of posts doesn't fill ...
0
votes
2answers
818 views

Get the category name outside of the loop in category.php

I am in a category.php, and I have to write the category name outside of the Loop. The category name needs to be pulled dynamically through PHP. <p>You are browsing <?php get_the_category ?&...
0
votes
1answer
130 views

Adding custom post type to count in category

I'm working on building a section for related posts in my theme's single.php file and I'm querying things based on the count returned from count (returned from get_the_category($post->ID);) The ...
0
votes
1answer
61 views

Calling Category name without the link

I have looked to see if there is a simple function that only returns the name of a category on a post. I am looking to output it as a subheading for a list of posts but do not want it as a link and ...
0
votes
1answer
341 views

Get 5 most recent categories

How can I get 5 categories ordered by publish date of it's most recent post? I basically need 5 most recent categories that were used in recent posts.