Fill the exclude array() in get_posts()

After three days of struggling and posting a question here I managed to find an answer. Yeh I know… To my defense I can say that it’s my first WP project. I did it this way: $exclude = get_excluded_parents(); $parents = get_posts( array( ‘post_type’ => ‘jhk_story’, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘numberposts’ => -1, … Read more

Counting Posts by Category

0 down vote accepted I think it would help you to read this => http://wordpress.org/support/topic//display-number-of-posts-per-category function number_postpercat($idcat) { global $wpdb; $query = “SELECT count FROM $wpdb->term_taxonomy WHERE term_id = $idcat”; $num = $wpdb->get_col($query); echo $num[0]; }

ACF query-pass field value

SOLUTION: $posts = get_field(‘choose_office’); if( $posts ): foreach(array_slice($posts, 0, 1) as $post): setup_postdata($post); $post_ID = get_the_ID(); endforeach; wp_reset_postdata(); endif; $args = array( ‘meta_query’ => array( array( ‘key’ => ‘office’, // name of custom field-post object ‘value’ => $post_ID, //name of relationship field ‘compare’ => ‘LIKE’ ), ), ); Solution from question: https://stackoverflow.com/questions/46816190/using-post-id-inside-reverse-acf-relationship-querie

WP_Query that targets all categories

It’s hard to say exactly why adding the category changes anything, but… The query looks OK… Almost… There are some things that concerns me: ‘post_type’ => ‘posts’, – there is no built-in post type called posts. You should use post in there, unless it’s your CPT (but then… I don’t think it’s a good name … Read more

Ajax load more inside custom post type taxonomy

Assuming the function hooked to the action load_posts_by_ajax is your load_posts_by_ajax_callback() code (seems a reasonable assumption), the query arguments can be easily modified. You mention “displays only 3 posts” which is what the code is designed to do. If you wish to show 10 posts, update the posts_per_page argument listed. ‘posts_per_page’ => ‘3’, The bigger … Read more