How to convert objects into arrays
$wpdb->get_results has a second parameter that lets you specify what kind of return value you want: For example: $data = $wpdb->get_results( $query, ARRAY_A ); Here you get an associative array back.
$wpdb->get_results has a second parameter that lets you specify what kind of return value you want: For example: $data = $wpdb->get_results( $query, ARRAY_A ); Here you get an associative array back.
If something needs to be “random” than the last post ( or the one before last ) will answer that definition well enough. Just because you know it is not a post generated by a randomizing algorithm do not mean it is not random to the user. There is just no way to have a … Read more
In order to access a variable defined in the global scope you must reference it with the global keyword wherever you want to call it again. In your case, the function create_year_terms() must call the global $year_arr within its scope. Also, you can always get your variable in the global scope by using the $GLOBALS … Read more
You need to have your replacement placeholders matching the number of values in your array, and then you can use the array as one of the prepare arguments. Proof of concept: $a = array(‘course_3202′,’course_3201′,’course_3200′,’course_3199′); $b = array_fill(0,count($a),’%s’); $b = implode(‘,’,$b); $sql = “SELECT * FROM $wpdb->postmeta”; $sql .= ” WHERE meta_key IN ({$b}) and meta_value=1″; … Read more
As Milo ( and your errors ) point out: you’re passing an array where a string is expected. According to WP_Query tag parameter Show posts associated with certain tags. tag (string) – use tag slug. To get around this you just need to pass a comma separated string: function custom_tags( $query ) { $query->set( ‘tag’, … Read more
Based on the testing that I did, the placeholder string Choose a category… cannot be filtered with the submit_job_form_fields filter, but there are still ways to change that string. One way to alter the text is to override the plugin’s default job-filters.php template with your own. Copy the default template, /wp-job-manager/templates/job-filters.php over to your theme: … Read more
It is an object, and you can use the following notation: <?php echo $myterms[0]->name; ?>
Assuming this array for example usage: $options = array( “name” => __(‘Font’,’mytheme’), “desc” => __(‘Change the font face)’,’mytheme’), “id” => “mytheme_font”, “std” => array(‘size’ => ’10px’, ‘face’ => ‘Arial’, ‘color’ => ‘#000000’), “type” => “text”, ); For question 1, to reference nested arrays, just reference them directly. echo $options[‘std’][‘size’]; In the form input, if using … Read more
What WP does for arrays (and objects) on some contexts (such as post fields) is using maybe_serialize()/maybe_unserialize() to turn such types (and just them) to and from serialized (string-typed) representation. While this simplifies workflow it comes with penalties, such as being unable to properly query through such data and common issues with migration (seriazlization-unaware tools … Read more
tax_query requires an array of arrays, and $the_taxes is an array of arrays, you’ve already got 99% of your answer. foreach ($taxes as $tax) { $the_taxes[] = array ( ‘taxonomy’ => $tax, ‘field’ => ‘term_id’, ‘terms’ => $terms, ); } $the_taxes[‘relation’] = ‘OR’; $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => $the_taxes, );