Questions tagged [get-the-category]

get_the_category ( int $id = false ) retrieves post categories. It can be used outside The Loop by passing a post id as the parameter.

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

Why does the first category returned get echoed twice?

I have a category called menu items (category id 19) and two child categories Tacos and Burgers. Why does Tacos get echoed out twice? I get Tacos Tacos Burgers. while (have_posts()) : the_post(); ...
0
votes
2answers
2k views

How to fetch the highest category in the hierachry for a specific post?

I understand Wordpress concept "primary category", but I do not understand how to fetch the name of the highest category in the hierarchy for a specific post? Having this code: $category_obj = ...
0
votes
1answer
2k views

Get Attachment Category Name

How can I call the name of an attachment category? Something that would look like <?php get_attachment_category_name ?> or $attachment->category_name This would simply output the name of ...
0
votes
1answer
687 views

Get the categorie name of Event Organiser plugin [closed]

How can I get the name of a category in a custom template of the Event Organiser Plugin. So far the only thing I can get it slug of the category by reading the following variable: echo $...
0
votes
1answer
521 views

Category ID returns as '0'?

I'm trying to populate the category id from the category name within the loop. <?php $cat_name = get_theme_mod( 'cat_1' ); ?> <?php $category_id = get_cat_ID($cat_name); ?> &...
0
votes
1answer
3k views

Display post list within category list sorted by name [duplicate]

I'm trying to display a list of categories sorted by name and all posts of each category inside it. Like this: Category A Post B Post F Post Z Category B Post A Post C Post G Category C Post D ...
0
votes
1answer
2k views

Category with description and thumbnail

I am using the below codes to show all Parent Terms from a custom taxonomy with title and link on a page. But I want to show the parent term description, thumbnail and post count in it too. So how I ...
0
votes
1answer
901 views

Display the category name of a post that is in two different categories

I'm trying to get the category of a post that is in 2 different category. One category is always "Featured" and the other changes. I can only see the word Array() This is my code: <?php $args = ...
0
votes
1answer
490 views

the_category if/else statement

I need to do the following: The sense if I have a class dportfolio - show a category dportfolio. Otherwise show usual category. I use: if ( class_exists( 'DPortfolio' ) ) { echo DPortfolio::...
0
votes
1answer
140 views

Highlight posts that belong to current sub category

I'm trying to highlight list items that belong to the same category as that of the current category page. For an example, I have a category called food, with the subcategories: breakfast, lunch and ...
0
votes
2answers
3k views

Display post category in foreach loop with category link

I have the following code to show current author post lists with post thumbnail, post title, post date and post category. function my_get_display_author_posts() { global $authordata, $post; $...
0
votes
1answer
164 views

Show post if in category

I've searched a lot for options like has_category, in_category, get_the_category, but I couldn't make them work Here's my pastebin http://pastebin.com/Zi7auvtv I want this code to run only if the ...
0
votes
0answers
560 views

Help with Wp + Mixitup code

I'm using MixItUp and having this issue. I'm calling the filters like this: <?php $categories= get_categories('child_of=14&hide_empty=0'); foreach ($categories as $category) echo '<li ...
0
votes
1answer
507 views

How to get tags and categories?

I used the following code to get tags from the post and then simply echo them: $posttags = get_the_tags($post->ID); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . ', ';} ...
0
votes
1answer
731 views

Pluck single parent category from get_the_category

I am working on a theme that displays a single category for each post. However to eliminate user error, I would like to pluck a single parent category out of a posts categories. Here is my code as ...
0
votes
2answers
923 views

Hook into create_category

I'm trying to in some way hook into when a new category is created. What I would like to do is to see the term and slug that was created and log them/email them. I have tried to hook in to ...
0
votes
1answer
149 views

My custom query not detecting the correct category

For category.php my custom query code isn't displaying the posts from the correct category. I have a parent category called 'Blog' and it can have any number of unknown children. With that in mind I'...
0
votes
2answers
833 views

Show single Child Category on Custom Post

Am hoping someone can help me pull out a single custom category name and show it on my custom post page. I've created a new custom post type 'Itinerary' as well as some new custom categories (terms): ...
0
votes
1answer
3k views

Display 1 category only with get_the_category (by ID or slug)

After hours of unfruitful Googling, I am asking for your help on this issue. My objective is to display only 1 category with get_the_category if the category ID matches the ID or slug set in the ...
-1
votes
1answer
94 views

How to display a linked category name with get_the_category

I a code snippet with this bit included... $output .= '<li><a href=" ' . get_the_permalink() .' ">' . get_the_title() .'</a> ' . get_the_category() .' '. get_the_time('d M Y') . '&...
-1
votes
2answers
91 views

Not able to display category link and name [closed]

I bought a wordpress theme and I am not able to display the category link and name. <div class="item-info">'; if($show_aut!='0'){ $author = get_author_posts_url( get_the_author_meta( '...
-1
votes
1answer
2k views

How to control order when displaying child categories

I'm working on displaying a series of child categories in the meta of each post. For instance, after the post appears an array, depending on category selection, describing the post content: Color: ...
-1
votes
1answer
17 views

Print the associated categories of the current post starting with parent (with option to remove href)

Not sure why this seemingly elementary function is so difficult to perform, but I've spent a lot of time scouring the web, incorporating the suggestions and not getting the intended output. On the ...
-1
votes
1answer
34 views

Why does my Wordpress index has a category?

So my homepage is set to display the latest articles of my wordpress site. I use php to detect if the page has a special category in the header of my template and it works on every other pages at the ...
-1
votes
1answer
2k views

Link Back to Parent Category - Woocommerce

I´m using woocommerce and a custom post type=product and taxonomy=product_cat. I need a link back to parent category on every single product and category pages. Already read several posts in the web ...
-1
votes
1answer
527 views

Print child category slug nicename

I want to print (display) the child category slug, so I can use it in a dynamic url, on categories pages. So If I am on the category www.example.com/category/main-category/child-category Example: ...
-1
votes
1answer
61 views

How to display my categories in a list (to a post, not the sidebar)?

i want to display my categories to a post like a list. i have this (parent- and child-) categories: - Sports - Football - Basketball - Toys - Dolls - Lego - Books for example one ...
-1
votes
1answer
5k views

Get first category only and excluding one

How can I get the first category (linked to the category archive page) of a post excluding the category called 'featured'? I found various solutions but I can't combine them properly. Thanks UPDATE: ...
-2
votes
1answer
45 views

How to insert the first letter in uppercase [closed]

short question, I have a variable concatenated with a get_the_title and get_the_category, and I need the get_the_category to show the first letter in capital letters. <?php echo get_the_title().' ...