Sum and count of custom field values

Thanks for your help guys. They didn’t quit work exactly, but I managed to get the result I needed by doing the following $reviewsNum = 0; $reviewsCount = 0; $argsSchema = array( ‘post_type’ => ‘reviews’, ‘posts_per_page’ => -1 ); $loopSchema = new WP_Query( $argsSchema ); $count_reviews = wp_count_posts( ‘reviews’ )->publish; while ( $loopSchema->have_posts() ) : … Read more

Order get_terms by multiple meta_values

That is because get_terms() does not accept array type as a value for the ‘orderby’ parameter. The documentation says about this parameter: ‘orderby’ (string) Field(s) to order terms by. Accepts term fields (‘name’, ‘slug’, ‘term_group’, ‘term_id’, ‘id’, ‘description’), ‘count’ for term taxonomy count, ‘include’ to match the ‘order’ of the $include param, ‘meta_value’, ‘meta_value_num’, the … Read more

ul list with only as many li’s as filled custom fields

You could add a check to only display the item if it exists: <?php if ( $imagen4 ) { ?> <li class=”artiq-slidder-item”> <img src=”https://wordpress.stackexchange.com/questions/269610/<?php echo $imagen4[“url’] ?>”></li> <?php } ?> But it looks like you are using the Advanced Custom Fields plugin. If this is the case, you would probably be better off using a … Read more

Pass fileurl parameter into shortcode from Advanced Custom Fields

Do not use echo in your shortcode. Use return instead. function get_generic_demo() { //Get the field’s value $demo = get_field( ‘generic_demo’); //Save the URL into a variable $url = $demo[‘url’]; // Pass it to the other shortcode and return its value return do_shortcode(‘[sc_embed_player fileurl=”‘.$url.'”]’); } add_shortcode( ‘generic_demo’, ‘get_generic_demo’); Also make sure your fields contain the … Read more

How to show Advanced Custom Fields data above share links, pagination, etc

Plugins typically insert their content via the_content filter. The filter runs when the_content() function is called, and passes the content through the filter before output. Remember, with a filter, you need to append to the existing content, then return the results. add_filter( ‘the_content’, ‘wpd_content_filter’, 10 ); function wpd_content_filter( $content ){ if ( is_single() && get_field( … Read more