Show one post per author and limit query to 8 posts

I believe that you can achieve this effect by grouping the query by author ID, which will require a filter(mostly cribbed from the Codex): function my_posts_groupby($groupby) { global $wpdb; $groupby = “{$wpdb->posts}.post_author”; return $groupby; } add_filter( ‘posts_groupby’, ‘my_posts_groupby’ ); If you have less than 8 authors, however, this won’t work. (You will get a number … Read more

settings api store multiple array

I put this in the form so it knows its editting: <form method=”post” action=”options.php”> <?php settings_fields(‘venues_section’); ?> <input type=”hidden” name=”editmode” value=”<?php echo $editmode; ?>” /> <input type=”hidden” name=”venue_id” value=”<?php echo $venue_id; ?>” /> <?php submit_button(); ?> </form> The receiving validation function can then handle that by doing something like this: function venues_validation_callback($input){ $venues = get_option(‘venues’); … Read more

use get_posts to get custom field data, but in one array

You can alter your foreach loop as following to get concert date and city pair in single multidimentional array as following. $concert_query = array(); $i = 0; foreach($c_query as $post) : setup_postdata($post); $concert_query[$i][‘concert_date’] = get_post_meta(get_the_ID(), ‘concert_date’, true); $concert_query[$i][‘concert_city’] = get_post_meta(get_the_ID(), ‘concert_city’, true); $i ++; endforeach; print_r($concert_query);

Make Selected Mutiselect Items “selected”

I’m assuming your $selected variable contains an array of values for the currently selected items? You can’t use selected in this case (with multi select boxes) because it only compares two strings. It won’t test to see if the value is in an array. Instead, use a ternary statement and in_array() <?php foreach ($cats as … Read more

Creating a unique, linked list of tags from a specific category?

You can build a stack of unique tags, then loop over them again to output. Couple of extra things though – never use query_posts. Secondly, you can be way more efficient in your querying and save a lot of memory in the process: $post_ids = get_posts( array( ‘posts_per_page’ => -1, ‘category_name’ => ‘testing’, ‘fields’ => … Read more

post__in works but also prints the word Array

Array is how PHP represents an array when it is converted to a string: echo array( /* anything in here */ ); // output: Array Fortunately for you, PHP doesn’t really like converting arrays to strings, so it will give an error like this: PHP Notice: Array to string conversion in /somefile.php on line 345 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)