Does meta_value (array) work with ‘orderby’?

Researching more, I got it to work with the following code $post = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘category-1’ ), ‘meta_query’ => array( array( ‘key’ => ‘custom-key’, ‘value’ => array(1,100), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘NUMERIC’ ) ), ‘meta_key’ => ‘custom-key’, ‘orderby’ … Read more

How do I create a numbered list with PHP? [closed]

This is pure PHP. $items = get_post_meta($post->ID, “item-specific-meta”); $item_id = 1; $output=””; foreach ($items as $item) { $output .= ‘<label for=”item-‘.$item_id.'”><input id=”item-‘.$item_id.'”/>’.$item.'</label>’; ++$item_id; }

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

Hide sidebar if post_type is in array

This is more php, but you can use in_array(). Just check if the current post type is in array in $hide_sidebar. You can do the following $hide_sidebar = array(‘example1’, ‘example2’, ‘example3’); //hide sidebar on these post types if ( in_array( get_post_type(), $hide_sidebar ) ) { // Do something if the post type is in array … Read more

Get archives as array

If you look at wp_get_archives() you will notice that the link is generated by get_archives_link(). That function supplies a filter that will allow you to replace the parens. This is fairly crude but does work. function archive_link_wpse_183665($link) { $pat=”|\(([^)])\)</li>|”; // preg_match($pat,$link,$matches); // var_dump($matches); $link = preg_replace($pat,'[$1]’,$link); return $link; } add_filter( ‘get_archives_link’, ‘archive_link_wpse_183665’ );

Get html data with javascript to php array and store to wordpress database

Here is my own solution. In my html I’ve assign id to all the item and inside the form I’ve added an input option where I pass the value through the script and it was saved later. Simple… script jQuery(document).ready(function($){ $(“.sortable”).sortable({ connectWith: ‘.sortable’, receive: function (event, ui) { document.getElementById(‘hello1’).value = myFunction(); }, out: function (event, … Read more

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