Cant get unique_array() work on get_the_category() foreach loop
Cant get unique_array() work on get_the_category() foreach loop
Cant get unique_array() work on get_the_category() foreach loop
The terms parameter will only accept custom post types and, like you mentioned, post-format-standard is not one. Try instead to use the ‘NOT IN’ operator to test against the custom posts you don’t want to display (all in this case): $query = array( ‘showposts’ => 5, ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘OR’, … Read more
As Milo mentioned, this is an Advanced Custom Fields plugin (ACF) question. As such I have raised this ticket with the ACF support team here https://support.advancedcustomfields.com/forums/topic/how-to-replace-hard-coded-list-of-custom-taxonomy-terms-based-on-custom-field-qu/
Your options should have a key => value structure if you want it to return something other than the key number: ‘options’ => array( ‘option_a’ => __(‘option a’, ‘woocommerce’ ), ‘option_b’ => __(‘option b’, ‘woocommerce’ ) ) );
get_the_title takes an int, not an array of ints, and therefore returns a string, not an array of strings. So just break that bit out into a loop: $titles=””; foreach ($act_name as $act_name_item) { $titles .= ($titles ? ‘,’ : ”) . get_the_title ($act_name_item); }
It looks like you may be creating an array around a single long string that needs to be split up into array elements (assuming $idsposts is a string and not an array). Try using $myposts = explode(“,”, $idsposts); Instead of just adding $idsposts as the only element of your $myposts array. You can also check … Read more
Best luck while you learn. $fivesdrafts = $wpdb->get_results( ” SELECT ID, post_title FROM $wpdb->posts WHERE post_status=”draft” AND post_author = 5 ” ); foreach ( $fivesdrafts as $fivesdraft ) { echo $fivesdraft->post_title; } This example has been sponsored by WordPress codex. In your case $wpdb->get_results( Should become like: $variable_to_print = $wpdb->get_results(
You’re looking for the get_adjacent_post function. This is a built-in wordpress function that you can use to get either the previous or next post from the current post. To get the next post: $next_post = get_adjacent_post( false, ”, false, ” ); To get the previous post: $prev_post = get_adjacent_post( false, ”, true, ” ); You … Read more
I figured it out using a While loop and an If statement with a counter. This solution uses functions from Advanced Custom Fields; $i = 0; while have_rows(‘week_rows’) ): the_row(); $i++; if( $i == 5 ) { // stops on the 5th row of ‘week_rows’ array break; } endwhile; // I had to move the … Read more
$args = array( ‘post_type’ => ‘promo’ ); $loop = new WP_Query( $args ); $promos = array(); while ( $loop->have_posts() ) : $loop->the_post(); foreach((get_the_category()) as $category); $promos[] = $category->cat_name. ‘ – ‘ .get_the_title(); endwhile; echo ‘<script> jQuery(document).ready(function($) { var promoList=”.json_encode($promos) .”; $( “#auto-promo” ).autocomplete({ source: promoList }); }); </script>’;