The get-the-category tag has no wiki summary.
0
votes
1answer
17 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 ...
0
votes
0answers
20 views
WP current category - strange behaviour [closed]
I've use this code:
$current_id = get_query_var('name');
echo $current_cat;
$category_id = get_cat_ID($current_cat);
echo $category_id;
to get current page category number. Everything is working ...
1
vote
1answer
41 views
Insert <ul> Into Sub-child Menu
This code displays a list of child categories of the parent category while a user is on a child category or single post.
The styling around this list is displaying even when a list isn't being ...
1
vote
3answers
61 views
Add Class While on Current Post; wp_list_categories
The code below produces a sub-menu of child categories of the currently active parent category. This code also produces the child categories of the top parent category while viewing child categories ...
2
votes
1answer
126 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(
...
0
votes
2answers
277 views
Display the deepest child category from Category X (in loop)
I have a number of top-level categories including "News" and "Sport". They each have multiple levels of child categories as shown below.
News
Australia
NSW
Sydney
Sports
Cycling
Road ...
0
votes
1answer
139 views
Using wp_list_categories like the the_category (showing just current categories of a post)
fromi'm using wp_list_categories to get an unordered list with headlines (on single.php inside the post-loop):
<ul><?php wp_list_categories('title_li=0');?></ul>
the thing is: i ...
0
votes
1answer
24 views
Get only X number of categories
How can i get only x number of categories using the_category. I triesd a few thing but none worked. I dont want to use get_the_category
1
vote
1answer
62 views
Add classname to the_category() function?
is it possible to use add_filter or something similar to add the slug of the category as classname to the the_category() function?
Right now when using the_category() the output looks like this …
...
0
votes
1answer
39 views
get_the_category_list open in parent window
I'm opening my posts in an iframe, and I'm using get_the_category_list to list post's categories. The problem is that when a user clicks on the category link, it opens in the iframe. How can I set the ...
0
votes
1answer
73 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
49 views
Finding and removing duplicates within WP Arrays
I'm looking to see if it's possible to find and remove duplicates from the arrays generated below. I've tried array_unique array_merge and they haven't worked.
$category = get_the_category();
$tags ...
0
votes
1answer
119 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
28 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
78 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:
...
3
votes
1answer
177 views
Change role after the user has read all the posts in a category
I'm creating a platform with "X" categories and "X" roles with the same name to each category.
I would like to know how to change the user's role after they have read all the posts in a category. ...
0
votes
1answer
134 views
Subcategory is displayed before Parent Category
I'm current using the following code to echo the categories of my post :
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?>
So, for example, I have ...
0
votes
3answers
48 views
Need help “sanitizing” a custom function that pulls category slug into body class
Not sure if "sanitizing" is really the correct phrase to use for this but it was the best one I could think of...anyways, here is the problem:
My function works great like so...
// add category id ...
0
votes
1answer
380 views
Outside the loop Category name with link
I want to display the category Name by using category ID with link to category page (out side the loop).
here is my code...
<a href="<?php get_category_link('23'); ?>"><?php echo ...
1
vote
1answer
73 views
Get only one of the current categories
On post pages Im using the below code to display links to other posts from the current category.
My problem is when the current post is in more than 1 category it will display posts from the first ...
0
votes
1answer
111 views
Get 1st parent category id from post
I have this structure for my categories:
Issue 4
- News
- Supporting our troops
- Breaking news
<?php
$category = get_the_category();
$parent = ...
1
vote
0answers
139 views
List only child categories within posts
I am using the_category() to display categories in my posts that are also filed in child-categories. Unfortunately this also displays the parent category which i would love to hide. Is there a way to ...
0
votes
1answer
202 views
How to correctly display category's slug as a class?
I want to display category's slug as a class.
I try to code and put this into functions.php
add_filter('the_category', 'my_custom_get_the_category_list');
function ...
0
votes
1answer
637 views
get_the_category listing in hierarchial order
Hello at the moment I'm wondering how I would be able to make this work to post in Hierarchical order within the post loop.
<?php
foreach ((get_the_category()) as $childcat)
{
...
0
votes
1answer
261 views
Better way to exclude category output for post/pages?
I always assumed there was a way to exclude certain categories from being output in the loop using get_the_category, the_category, or one of the term related functions. After looking around it seems ...
0
votes
1answer
166 views
Compare current post Category in select menu
i have done this many times but not via a form so i am getting a weird issues when trying to assign a "selected" based on the current post term id...
Maybe the use of get_the_category and then ...
0
votes
2answers
647 views
Can't Get Parent and Child Categories of Custom Taxonomy to Display
I have a Custom Post Type set up with a Custom Taxonomy. For this Custom Taxonomy, I'm trying to figure out how to echo out the titles of the parent category and current child category within it.
...
0
votes
3answers
762 views
get_the_categories() but exclude children of “Uncategorized”
In this function, I need to exclude any categories from $categories which are children of "Uncategorized".
function get_cats(){
$post_cats= array();
$categories = get_the_category();
...
0
votes
2answers
98 views
loop inside a loop : search for posts in the same category
Could someone tell me how i could make this work? i have a loop, and i would like to create another loop to find the other posts from the same category : but this does not work :
<?php while ( ...
0
votes
2answers
227 views
Why is get_the_category() saying that I have two categories?
My post has only one category. The following code:
$categories = get_the_category();
gives me this result:
Array
(
[0] => stdClass Object
(
[term_id] => 22
...
-1
votes
1answer
449 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: ...
0
votes
1answer
842 views
Test if post has a category
I need to display some HTML only if the post being displayed has a category - not a specific category, just any category at all.
I tried if (!is_empty(get_the_category($post->ID))), but for some ...


