How to get category id’s which are added in main menu?
Unfortunately is_category() not worked for me but if(in_category( ‘articles’ )) `in_category()` worked Codex reference for in_category().
Unfortunately is_category() not worked for me but if(in_category( ‘articles’ )) `in_category()` worked Codex reference for in_category().
In both your queries you are doing it wrong. You are running a separate instance of WP_Query for every argument set $args = array( ‘posts_per_page’ => $count, // Limit count ); $query = new WP_Query( ‘cat=1’ ); $query = new WP_Query( $args ); Should be $args = array( ‘posts_per_page’ => $count, ‘cat’ => 1 ); … Read more
If your theme has an attachment template (attachment.php) and you upload your page/post-specific media items, then you will get a page/post-specific media attachment URL. Suppose you are adding/editing your post/page on Case Study (i.e. cs1), so your post/page URL will be (if post-name permalink structure is enabled): http://example.com/cs1/ If you upload an image or a … Read more
I believe, most obvious choice would be to create two categories “Fall-Winter” and “Spring-Summer” and put four other categories in both of them. Your URLs would be like this /category/fall-winter /category/fall-winter/formal-wear /category/fall-winter/night-wear Now, to list the formal wear for both fall-winter and spring-summer on page, we have few following options Create formal wear etc as … Read more
How about creating those categories Cars, Tvs, Trains and Ships as sub categories of locations? Then you could have a navigation menu containing parent categories i.e Briton, Manchester etc. Once a parent category is navigated to you could have a menu that uses the get_terms() function with the parent argument set to the current location … Read more
My suggestion would be to pass different arguments to Wp_Query Class. using ‘cat’ property, passing category Ids. <?php $custom_query = new WP_Query( array( ‘cat’ => ‘1,2,3,4’ ‘post_type’ => ‘my_post_type’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ) ); ?> OR using ‘category_name’ property passing category slug’s as string parameters. <?php $custom_query = new … Read more
You could use tax_query to solve this problem. I assume 4 and 6 are only categories, so you’ll probably need to construct the queries within the $tax_query array rather than declare it, but let us know if that is a problem. Just remember that relation => ‘AND’ must be included. $tax_query = array( relation => … Read more
Thanks the the replies. I solved my problem with jQuery. Here is the code: jQuery(document).ready(function ($) { $(“#category-tabs li.hide-if-no-js”).hide(); //Hides Most Used tab $(“#category-all input:checkbox”).change(function () { var max = 2; // Max allowed cats var count = $(“#category-all input:checked”).length; //counts selected cats if (count > max) { $(this).prop(“checked”, “”); alert(‘You are only allowed to … Read more
I assume you want the field for the current category archive, not the category of the post inside the loop? Try get_queried_object_id() instead of the_category_ID( $echo ). In single.php, you just need a slightly different iteration of your original attempt: if ( $terms = get_the_category() ) the_field( ‘bgcolor’, ‘category_’ . $terms[0]->term_id );
posts_per_page=-1 is perfectly fine. This is used to get all posts. As for your code, you should never ever use query_posts unless you want to intensionally break stuff on your pages. This is one of the most common functions used and yet the one function that causes the most problems in a website. I have … Read more