Counting custom post type with wp_count_posts returns an empty object
Counting custom post type with wp_count_posts returns an empty object
Counting custom post type with wp_count_posts returns an empty object
to get the number of authors who are assigned a particular role the get_users() function should do it: $args = array( ‘role’ => ‘frontend_vendor’,//substitute your role here as needed ‘fields’ => ‘ID’, ); $users = get_users( $args ); $user_count = count( $users );
The category objects returned by get_categories() include a property of count: $lc->count
I needed to get the number of post per type per term so i created this small function: function get_term_post_count_by_type($term,$taxonomy,$type){ $args = array( ‘fields’ =>’ids’, //we don’t really need all post data so just id wil do fine. ‘posts_per_page’ => -1, //-1 to get all post ‘post_type’ => $type, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more
List Most Read Posts from last 7 days (with custom post type and other meta queries)
Link Button url count php and wordpress
You should be able to get that number from the same $wp_query object: global $wp_query; $num_pages = $wp_query->found_posts; $num_pages will contain the total count that matches your category (or whatever other criteria you’re using). If you’re just looking to get a string you can display, this modified version of the function will work. function get_post_number() … Read more
I found out a way to do this , turned out to be kind of easy here is what i did $Aschools = get_post_meta( get_the_ID(), ‘american_member_schools_field’, true ); $i = 0; $entries = count($Aschools); foreach ( (array) $Aschools as $key => $Aschool ) { $logo = $Aname=””; $i++; if ( isset( $Aschool[‘name’] ) ) $Aname … Read more
Just giving you a general idea which may help you. You can try something like below in WordPress – 1) Add a functionality to have usermeta as active or pending e.g. update_user_meta($user_id, ‘_user_custom_status’, ‘active’); 2) Do not show any post for non logged in user. 3) On login, check for user with subscriber role and … Read more
Hi I believe this should work <div class=”col-xs-8″> <?php $count = 1; ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if $count = 1; ?> <!– First post Wrapper–> <div class=”first-post”> <article class=”post1″></article> </div> <!– Rest all post Wrapper–> <div class=”all-posts”> <?php else : ?> <article class=”post<?php echo … Read more