Articles of get categories

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 subcategories. E.g. Issue 7 -> news journal worldview letters etc… I have a page which lists all of the parent […]

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 $catinfo->slug; ?> which isn’t printing anything, a var_dump($catinfo); produces the following: array(1) { [0]=> int(59) } In theory <?php print $catinfo->slug; ?> should print the taxonomy slug, but it isn’t? […]

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 ‘category’ taxonomy) $partners = array(); $partners_obj = get_categories(array(‘taxonomy’ => ‘partner-cat’)); $partners[”] = ‘-‘; foreach ($partners_obj as […]

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, ‘hide_empty’ => 0, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘depth’ => ‘1’ //NOT WORKING ); $categories=get_categories($args); foreach($categories as $category) { echo ‘<a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . […]

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 -Subcat2 -Subcat3 WHAT I NEED IS: When I click on Cat1 or Cat2, I need to display something like that: Repeat this action as long the […]

Exclude category by slug for for each loop

I am trying to exclude some categories from a for-loop. <?php $categories = get_categories(array(‘exclude’ => ‘apps, windows’)); ?> <?php foreach ($categories as $category) : ?> // the_loop <?php endforeach; ?> Even though no error is thrown, it doesn’t work: all categories are used in the loop. How can I exclude some categories by slug? I […]

wp_query display posts from same category of the post

On my post page I am trying to display list of other posts from the same category of the original post. So far I got this and this does not seem to work: <?php $args = array( ‘post_type’ => ‘article’, ‘posts_per_page’ => 5, ‘post__not_in’ => array( get_the_ID() ), ‘category’ => array( get_the_category() ), ‘meta_query’ => […]

Detect whether a page is a product subcategory page?

How can I detect whether current page is a product sub category page? I’ve tried with the following but it will always print out “NO” function is_subcategory($category = null) { if (is_category()) { if (null != $category){ $cat = get_category($category); }else{ $cat = get_category(get_query_var(‘cat’),false); } if ($cat->parent == 0 ){ return false; }else{ return true; […]

get_query_var() and permalinks

I have a permalink structure that looks like this, %category%/%postname% I have a category.php template coded up and and trying to pull of the post of a certain category, so for example my URL may look like this, /category/category1 I want all posts that are in category1 to be return however, when using the following […]

Query only Posts from Both of Two Category?

I have 3 categories, 1.OnGoing projects(cat id=’5′) 2.Completed Projects(cat id=’6′) 3.Upcoming Projects(cat id=’7′) and also i have another 2 categories:(Not a Sub Category) chennai (cat id=’10’) Dubai (cat id=’11) How to get the post from “OnGoing Projects” with “Chennai” category?(I like to Display -> OnGoing Projects on Chennai.) I have tried the following code: <?php […]