The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
12 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 ...
2
votes
1answer
332 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
0answers
13 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/ ...
0
votes
1answer
17 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. ...
3
votes
1answer
55 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
0answers
6 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
3answers
803 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
0answers
12 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 ...
0
votes
2answers
48 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
111 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
47 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
58 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
743 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 ...
0
votes
1answer
41 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
2answers
723 views

How to exclude specific category from the get_the_category(); array

In my loop I've added: <?php $categories = get_the_category(); $separator = ' '; $output = ''; if($categories){ foreach($categories as $category) { $output .= '<span ...
0
votes
1answer
22 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
177 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 ...
0
votes
1answer
139 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
229 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
37 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
23 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 ) ); ...
0
votes
0answers
13 views

Order categories thumbnails?

I have a video portal website and I want to show subcategory names under each video thumbnail. The code I use is this one: <?php $category = get_the_category(); echo $category[0]->cat_name; ...
1
vote
2answers
2k 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
78 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
36 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
75 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
125 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
63 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
43 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
151 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
76 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
260 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 ...
0
votes
1answer
595 views

Get posts from a top category and group by child categories

I have a CPT Called "Membres" (members in English). So after that I created a category called "Membres" and his child categories. Parent category "Membres" - Subcategory1 (3 post inside) - ...
1
vote
1answer
773 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
447 views

How to get parent category ID in single page template

How can I get parent category ID in single page template, outside of loop? $category = get_the_category(); echo $category[0]->term_id; The code isn't working outside loop correctly.
0
votes
1answer
204 views

Display recent posts from the same category as current post in sidebar

I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but ...
0
votes
1answer
92 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 ...
1
vote
1answer
139 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
812 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 ...
0
votes
1answer
43 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
888 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
201 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
186 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
267 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 ...
-1
votes
1answer
48 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
389 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
250 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
172 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
93 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
829 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 ...