The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
30 views

How to sort category by custom field value

I am using the following : $catargs = array( 'meta_key'=> 'category_custom_order', 'orderby' => 'meta_value_num', 'order'=> 'ASC', ); but I can get the ...
0
votes
0answers
23 views

How to query and group posts by category?

/* * Loop through Categories and Display Posts within */ $post_type = 'post'; // Get all the taxonomies for this post type $taxonomies = get_object_taxonomies( array( ...
-1
votes
0answers
23 views

get_category($ID) is returning null

I have the following code: $ID = get_the_id(); echo $ID; $cat = get_category($ID); var_dump($cat); The id is echoed correctly but $cat is logged as NULL. I've also tried: $cat = get_category($ID, ...
0
votes
0answers
19 views

Reorder get_the_category()

I'm trying to get categories to rank differently from alphabetically. An example would be a post about Pugs. I categorize it as Dogs and then Pets. $category = get_the_category(); echo ...
0
votes
1answer
24 views

Get all categories post is not in

I am trying to get a list of all categories that the current post is not in. I made it this far... $categories = get_the_category( $post_id ); $nocats = get_terms('category', array('exclude' => ...
0
votes
2answers
42 views

Unable to differentiate between two categories under custom post type on single.php

I have created A custom post type as mentioned in my older question When I try to use get_the_category() function to retrieve the category of the post(if it is symphony or noir). It returns "Array". ...
1
vote
1answer
26 views

Get the number of posts in a named category, outside the loop

I've managed to do this from a single.php file, inside the loop, but now I need to do it from another page. I need to find out how many live posts are in category named every story (slug is ...
1
vote
1answer
36 views

Get posts with at least one category in common with current post?

In single.php : I want to get all posts with at least one category in common with the current post. I tried reading through the wordpress codex documentation but I found it rather confusing (I'm ...
0
votes
1answer
101 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
0answers
26 views

HELP get categories, child and post

Have tried severals code from Codex but not working,is it possible to display posts on category pages as subcategory wise using this. Example : ** Main Category Page ** ** Sub category #1 ** – Post ...
0
votes
1answer
97 views

Get current_parent_category in a loop or Cat ancestor- big problem

Im having some trouble since a week now . .. I'm having a bad time with that ! I explain my situation: I have setup a style for post category. (a background-color and a small image background). ...
0
votes
1answer
64 views

Related content based on category name

I'd like to modify the code below so it grabs the data based on the category the post is in and 'only' that category, not children categories, not other categories, only the category of the current ...
-1
votes
2answers
203 views

How to show WordPress Parent and child category different PAge?

I am currently trying to do a directory style site, and I currently have parent categories and child categories. Right now I have the parent categories showing and when you click on the parent it ...
0
votes
1answer
154 views

Get category name from custom loop and echo it once

I have a magazine front page that updates with every issue, and the front page shows the current issue posts which are stickied. So for example, this month all the posts are in a category titlted ...
0
votes
1answer
166 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
0answers
64 views

Get link to top-level parent category of post

I am trying to create a link to the top-level parent of a given post. Many of my posts are in sub-categories. I intend to place a 'root category' image that links to the root category. I have tried ...
0
votes
1answer
57 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
83 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 ...
0
votes
1answer
201 views

How to get only the last child of category slug?

DESCRIPTION I want to get the name of the slug of the last child of the post's category. My categories of my posts represents cities and I am assigning them 3-4 level categories as continent, ...
0
votes
1answer
56 views

Output the text before category

I need to output the text before the_category. In result, it should be something like Posted on September 20, 2014 IN MyCategory Here I use the_time('F j, Y') and start from here I use ...
0
votes
1answer
892 views

Display Categories or Subcategories with name & description in category.php

I have the following issue for my customer. Can some suggest a possible solution to this issue? This website has Categories & Subcategories Cat1 -Subcat1 -Subcat2 -Subcat3 Cat2 -Subcat1 ...
0
votes
1answer
214 views

the_category() tag not styling HTML or CSS

I am having problems getting my the_category() template tag to style accordingly with the rest of my theme. I believe this is because the HTML isn't output the same way as the the_author() and ...
2
votes
1answer
93 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. ...
0
votes
0answers
17 views

Category Link to Post

I have a website with categories X, Y, Z...with the Search Everything plugin I can search based on the category name to return all the posts within a given category. I have the search results posts ...
0
votes
0answers
19 views

Category name from custom fields

I have a problem with getting category name. I was trying a few versions of code and I don't have any idea how to run it correctly. I have custom field (field type - taxonomy-category/ ...
1
vote
2answers
136 views

How to add a rel attribute to images that contains their categories?

I've added categories to images, so that I can use them to filter images within a portfolio page. Now I'm thinking I need to add the rel attribute to each image that contains its assigned categories. ...
0
votes
0answers
23 views

How to Create Category Template list Subcategory?

im have database category -Category 1 --S1 Category 1 --S1 S1 Category 1 --S2 S1 Category 1 --S2 Category 1 -Category 2 --S1 Category 2 -Category 3 How to create check in Category as: Is go to ...
0
votes
0answers
23 views

Get first page of given category

I am not a WordPress expert, so I'm seeking your help. I need parent ID of post category (closest parent, not "grand-parent"), then use it to get the first post of that category. I have folllowing ...
4
votes
1answer
93 views

How to add classes to images based on their categories?

I need to be able to: 1.) assign categories to images and 2.) add classes to all images that correspond to their assigned categories. I was able to add categories to images with the following: ...
0
votes
3answers
482 views

Exclude one category from get_the_term_list

I want to exclude one of the categories from my posts, which will always be the same, named "documentaires" and with the ID 20. Here is the code : <?php echo get_the_term_list( get_the_ID(), ...
2
votes
1answer
154 views

Get a variable from object in array [closed]

I'm trying to echo get_the_category($id)[0]->slug and this works on localhost but not on the server. The error is Parse error: syntax error, unexpected '['.... Is there a workaround?
0
votes
1answer
274 views

Anchor tag generates blank href attribute using echo esc_url( )

Following is my categories page. It's listing the all categories in the page. But when <a href> gets blank value here. see the attached screen shot. Why href is blank here li><a ...
1
vote
2answers
239 views

Apply different Class for each element in a foreach()

sorry for the silly question, but I am really lost. I want to apply the following CSS to the even elements of my foreach. CSS .blogArticles a { float: left; max-width: 250px; width: 25%; ...
0
votes
1answer
212 views

Exclude category from get_the_category

I want to exclude a specific category from the loop, here's what I tried: Original code: // auto posts by cat if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == ...
0
votes
1answer
42 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
526 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
2answers
1k views

Display post category in foreach loop

I am trying to display post category in a foreach loop. I have all the elements displaying properly except for the category. Here is my function: function my_get_display_author_posts() { global ...
-1
votes
1answer
803 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 ...
0
votes
1answer
99 views

Can't get Category link inside get_posts

I created a simple function to display the latest posts. Inside the function there is a conditional to display the post category. I found that to display the category name, using $category = ...
0
votes
1answer
116 views

Category Page Template - Can't get category ID

I am creating a category template that uses WP_query to get posts from my custom post type... <?php $query = new WP_Query( array( 'post_type' => array( 'mycpt' ), 'posts_per_page' => 5 ) ); ...
6
votes
2answers
7k 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(); ...
0
votes
1answer
224 views

How to Highlight current category on category and single page template?

On Wp Forums, I found a code that shows categories with images and it works very well. But I couldn't figure out how to highlight current category on category.php and single.php Here is the code that ...
0
votes
1answer
47 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 ...
1
vote
1answer
115 views

Display post X of Y in category

I am trying to display a post number (X) on each single.php, based on what number that post is in it's category, followed by the total number of posts (Y) in the category. So if there is 10 posts in ...
0
votes
0answers
272 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 ...
-1
votes
1answer
89 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: ...
0
votes
1answer
70 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
306 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
1answer
181 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 ...
1
vote
1answer
547 views

Add body class of category parent

I am not a coder, but I usually get by with Wordpress by doing my research and find my solution. I can't find what I need to do this time so I have attempted to crib together some code - what I am ...