WP Page Options Array

After much experimentation I resolved my own question and this answer might help somebody. function mmm_select_field( ) { $options = get_option( ‘mmm_settings’ ); $buttons = array( ‘Bold’ => ‘bold’, ‘Italic’ => ‘italic’, ‘Underline’ => ‘underline’, ‘Superscript’ => ‘superscript’, ‘Align Left’ => ‘alignleft’, ‘Align Center’ => ‘aligncenter’, ‘Align Right’ => ‘alignright’, ‘Bullet List’ => ‘bulletlist’, ‘Number … Read more

Do not replicate items if they exists in a foreach loop

Just set a flag to check for a new value, and only display the date if the new value does not match the flag, like so: <?php $args = array( ‘post_type’ => ‘tv-schedule’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ‘post_status’ => array(‘publish’, ‘future’), ); $posts_array = query_posts($args); $flag = ”; // set … Read more

Matching slug terms from one array to those in array of WP_Term objects to output term names

Perhaps array_map ? This will give you an array of term names which matched your slugs in $active_filters: $matched_terms = array_map(function($term) use ($active_filters){ if(in_array($term->slug, $active_filters)){ return $term->name; } else{ return false; } }, $tax_terms); //remove the empty array elements which came from terms which didn’t match a slug $matched_terms = array_filter($matched_terms);

Obtaining array item from WordPress revisions output

To get the post author ID you can try: $revisions = wp_get_post_revisions($post->ID); //For first author $first_author = $revisions[0]->post_author; //to get all revision authors foreach( $revisions as $revision ){ echo $revision->post_author; }

How to get a page array and category array going at the same time?

extend this line: <?php if (is_page(array(‘page-one’, ‘page-two’, ‘page-three’,’page-four’))) $logo_image=”subLogo.jpg”; with || is_category(array(‘cat-1’, ‘cat-2’)) so you get, for example: <?php if (is_page(array(‘page-one’, ‘page-two’, ‘page-three’,’page-four’)) || is_category(array(‘cat-1’, ‘cat-2’)) ) $logo_image=”subLogo.jpg”; http://codex.wordpress.org/Function_Reference/is_category

Obtaining values from objects

The problem with your use of foreach (in both cases) is that you are erasing any previous value $Comments or $CommentDates had before the current iteration. Rather than setting the value to the variable itself, perhaps you should be appending new values onto the variable as an array: // Not sure what purpose your $cake … Read more

Saving array keep adding length of array

update_post_meta is maybe_serialising. And in this case is storing it as a serialised string The string your passing isn’t a correctly serialised array. If you pass it the raw array it will self convert it to the correct serialised string. The correct string is a:1:{i:0;s:4:”test”}, passing that shouldn’t serialise but probably will. You are betted … Read more

Array in meta key?

A postmeta value can be an array. You save it the exact same. Updating/Getting postmeta will detect if the value is an array/object, and serialize the value so it can be stored in the database. // Saving $users = array( 5, 20, 25, 29, 30 ); $saved = update_post_meta( get_the_ID(), ‘registered_users’, $users ); // Getting … Read more

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