Adding a block with query in homepage

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

How to link a PDF file to a category URL

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

Multiple categories for one menu item?

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

More efficient way to list posts by category [duplicate]

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

How to restrict the amount of categories/post tags/terms for a post type post

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

ACF no print data [closed]

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 );