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.

learn more… | top users | synonyms

5
votes
2answers
948 views

get_terms vs. get_categories: does it matter?

I'm fairly new to wordpress and am coming across new things each day - one was today when I happened across get_terms and noticed that it was basically the same as get_category. Any particular ...
3
votes
2answers
4k views

How To Get Parent Category Slug of Current Post

My theme has styling by category using the following code, which inserts the current category's slug as a CSS class. <div class="CategorySpecificStyle <?php $category = get_the_category(); ...
3
votes
2answers
7k views

get_categories hierarchical order like wp_list_categories - with name, slug & link to edit cat

I need to find a way to list all categories - empty or not - in a hierarchial list - like wp_list_categories - also showing the slug, cat name and a link to edit in the admin. Here is what I have so ...
2
votes
1answer
1k views

Only list categories that contain posts of a specific custom post type

I have three custom post types set up, articles, videos and photos. I am using standard categories for these post types, and sharing the categories across all post types. I am trying to create a nav ...
2
votes
1answer
286 views

get custom post type categories

From http://codex.wordpress.com: $categories = get_categories( $args ); $args = array( 'type' => 'post', 'child_of' => 0, 'parent' => ...
2
votes
1answer
62 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. ...
1
vote
2answers
370 views

Showing current subcategory

I have problem. <?php query_posts('category_name=events&posts_per_page=2&offset=1'); ?> <?php while (have_posts()) : the_post(); ?> <div> <?php $children = ...
1
vote
2answers
348 views

Highlight current category, when using get_categories

I'm successfully using helgatheviking's answer from this post: Show children of top level category only See code below: // get the category object for the current category $thisCat = get_category( ...
1
vote
4answers
3k views

Display Image for a category using get_categories, or show an image from any child post

I am using get_categories to list the child categories of a parent category. I want to add an image to the child categories, using the get_categories output. I can either take the featured image ...
1
vote
1answer
1k views

get_category_link() is returning nothing

<?php $categories=get_categories('taxonomy=galeriak'); foreach ($categories as $category) { ?> <li><a href="<?php echo get_category_link( $category->term_id ) ?>" ...
1
vote
1answer
132 views

display taxonomy slug from term ID

I'm trying to display the taxonomy slug from the term ID, thus my current code is like so: <?php $catinfo = get_category(array_pop(get_sub_field('sector_selector'))); ?> <?php print ...
1
vote
1answer
142 views

Show only first children level of current category?

I wish to display only first level of subcategories on current category page (if any). I tried this code: <?php $args=array( 'child_of' => $cat-id, ...
1
vote
1answer
59 views

Getting category before saving post

I am using the filter "wp_insert_post_data" to decide what to save to the database. I need to know which category has been picked before saving the post. How can I get to know the category that has ...
1
vote
1answer
2k views

Custom widget using get_categories select menu dropdown

I have created a custom widget that is supposed to display a select menu with all the categories the blog has. I have used get_categories to compile the list. This works fine and all categories appear ...
1
vote
1answer
720 views

Parent Category link to its sub categories on different page

I am creating a magazine style wordpress site. We have multiple issues which will be parent categories and these will have around 3-5 sub categories. Every quarter we will create a new issue with new ...
1
vote
4answers
165 views

Echoing Categories only if they're a child of a given category

I've got posts that I want to echo after the post content the categories only if they're a child of a given parent category. Example: Parent category: Goal Child categories of "Goal": brand ...
1
vote
1answer
249 views

List all categories in options

I used to use the following code to make the list of all categories: foreach($categories as $cat) { print '<label>'.$cat->name.'</label>'; print '<input type="text" ...
1
vote
2answers
2k views

wp_list_categories: get latest featured_image of category

I was thinking about a nicer way to display the categories in my sidebar. Instead of a plain list style, I'd like to have images / thumbnails show up as well. Currently I'm using the following: ...
1
vote
1answer
29 views

Proper syntax or method for keeping url in modified isotope / category links

I'm setting up a project gallery using isotope jquery plugin for layout and filterability. I've seen examples of how to add a list of category links and modify them to filter on click, but... I want ...
1
vote
1answer
413 views

How to display only subcategory

I have categories: -Parent category --Subcategory ---Grandcategory How i can display parent category and only subccategory(not display grandcategory). My args: $args = array( ...
1
vote
2answers
615 views

get_categories() for only CPT

On the site that I am working on I have Jobs as a custom post type and Locations as custom taxonomy. The Locations are used by Jobs, Posts, and other CPTs. I am working on a small filter for the ...
1
vote
1answer
2k views

How to call in Custom Post-Type Categories?

I have our portfolio page here: http://www.slarc.com/portfolio-view/central-control-building-east-texas/ The orange links below the project title are manually inserted on the page content. Is there a ...
1
vote
1answer
241 views

Category Foreach keeps looping?

I'm using the following code to acquire all the child categories of a category and displaying the child posts of the child categories. <?php $cats = get_categories( 'child_of='.get_query_var( ...
1
vote
1answer
298 views

List Sub-Categories of a Parent Category

I need to be able to list categories that are the sub-category of a specific category that is a sub-category of a primary category. So something like this: Print Categories where ParentCategory = ...
1
vote
1answer
131 views

Get subcategories with JSON API plugin

How to get subcategories with JSON API wordpress plugin? I see how to get categories, but what is the way to get categories with subcategories at the same time? How should I modify the existing code? ...
1
vote
2answers
158 views

get only sub category ID

i need to get only sub category ID. i already get sub category id but it coming with main category id too bellow is code <?php while ( have_posts() ) : the_post(); ?> <option ...
1
vote
1answer
234 views

Trying to sort and display categories(not posts) by custom field: 'order'

I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in ...
1
vote
0answers
22 views

Show category name and new articles and display page numbers. What function to use

Show category name and new articles and display page numbers. What function to use. Ex. cat name 1 -listcat1 1 update -listcat1 2 update -listcat1 3 update -listcat1 4 update cat name 2 ...
1
vote
0answers
781 views

get_categories listing foreach with children

My code for loop of categories <?php $categories = get_categories('hide_empty=1&exclude=1&orderby=slug&order=ASC'); foreach ($categories as $category) { echo '<li ...
1
vote
1answer
107 views

Creating a custom feed for categories that includes the first post's featured image

I'm needing a little help getting this figured out. I have a query that's not quite working right now, but I need it to create a custom feed that includes category information and then includes the ...
1
vote
1answer
2k views

How do I get the category slug from wp_dropdown_categories

This might be a newb question, but I'm not sure. I did wuite a bit of searching, but i can't find anything to answer my question... I am customizing a plugin I needed it to show a list of the ...
1
vote
1answer
106 views

Trying to add cat_ID to array for showing an image for specific Category

So OK....I might be way of but here goes. Im using a plugin that gives the post a Featured Image if its not set. So Im trying to make it that depending on in which category the post is in the Featured ...
1
vote
0answers
60 views

List posts in a category grouped by other categories?

I have posts of stores and restaurants in my area. Each post is marked by category of type (e.g. Restaurant, store) and town. What I am trying to do is create a page for each town (with intro text ...
1
vote
1answer
1k views

How to make multiple sections in home pulling posts category wise?

This question may look foolish to everyone or novice , but i am working on a theme . It will be basically a news publishing theme . Right now , In my home page all posts are showing one after ...
1
vote
0answers
298 views

Why is my 'list_terms_exclusions' filter function timing out? [closed]

Why is my function timing out? When the issue was first noticed I added wp_defer_term_counting('true') to delay that process but to no avail. /* Filter category from get_categories and ...
1
vote
2answers
105 views

User Defined order on get_categories?

Below is some basic code to call specficic categories to our front page post loop. It works fine, except my client wants the categories displayed in a particular order. I know there are other posts ...
0
votes
3answers
104 views

How to show more than 5 posts?

I am running code that shows child categories, and all posts in the child categories. But if there are more than 5 posts in a category, only the 5 newest are shown. How can I show all, or at least ...
0
votes
2answers
8k views

Get the category from an ID of a product?

I have the ID from a product (1345) how can i get the category name of that specific product? I try $post_categories = wp_get_post_categories( $post->ID ); print_r( $post_categories ); but it ...
0
votes
2answers
664 views

Get only the top level categories using get_categories() without foreach loop

Very simple Question: Here is my get_categories() code: <?php $args = array( 'show_option_all' => '', 'show_option_none' => '', ...
0
votes
2answers
133 views

Categorie parents and childs displayed

I'm trying to create a menu directly hard-coded, basically I need to display the parent category and below its child categories, however I have to do this several times meaning something like this: ...
0
votes
2answers
21 views

Undefined property: stdClass::$id when retriving term ID

I have the following: foreach( $this_post_terms as $term ) : $thiscat = get_term_by( 'slug', $term->slug, 'categories_whatever' ); echo $thiscat->ID; endforeach; The last line throws an ...
0
votes
2answers
161 views

Difference between get_category, get_term_by and get_categories

get_category is returning null but using get term_by or get_categories() is not. Why? I have created term called categorycourses. I have a post related to coursecategory Lidköping (vardump1), ...
0
votes
1answer
169 views

Define specific category name in PHP

Might be a really simple question... I am trying to pull out a category name in PHP and display it on my page. I have multiple category sections on this page, and each need to pull their respected ...
0
votes
1answer
1k views

Category 'pad_counts' & 'parent' conflict

Below is the current loop I have setup: <?php //start products category loop $args = array( 'hide_empty' => 0, 'parent' => 0, ...
0
votes
2answers
276 views

Loop through categories and create tab for each

I'm trying to create a page that holds all categories of my custom post type as tabs, with a tab content. I am able to display all the category names as tabs, but i need to run a query in each tab ...
0
votes
1answer
63 views

How do I get the parent category if I know the child category?

So Ive got this function here that creates a drop-down menu from only the child categories, it works great. The problem is that I need to get the parent categories name and assign it as the value of ...
0
votes
1answer
67 views

Loop Problem: Displays same set of post for all categories

So, I have 2 loops, one inside the other. The first to get the category titles, the second to display a few recent post from that category. Problem: Category titles display fine, but the recent post ...
0
votes
2answers
1k views

Trying to list terms of a custom taxonomy using get_categories

I'm using this little snippet of code to try and list the terms of a custom taxonomy for use in a meta box select box but it doesn't show anything when I implement it (Despite working with the default ...
0
votes
2answers
190 views

Get categories without post

I want to get categories that had NO post. Below is sql for getting category with post.. SELECT terms.term_id,terms.name,COUNT(post.ID) FROM wp_posts as post JOIN wp_term_relationships as rel ON ...
0
votes
2answers
188 views

Finding the category id's on category intersection pages

I'm using category intersection pages for users to be able to filter posts by categories. E.g. http://freemapsalgarve.com/category/destinations/alvor+bars-pubs/ Here the user is filtering on the ...