Can’t query by meta_key

Thanks for @dunc and @helgatheviking I got the answer. Here’s my code. You need the post type declared, otherwise it resorts to “post”. I also couldn’t do this unless I put meta_key and meta_value in a ‘meta_query’ multidimensional array. $args = array( ‘post_type’ => ‘tsa_events’, ‘meta_query’ => array( array( ‘key’ => ‘slideshow_image’, ‘value’ => array(”), … Read more

Build index page from custom fields

my suggesting is going for a different way by using get_pages() for example $args = array( ‘meta_key ‘ => ‘Partner_Level’, ‘meta_value’ => ‘Gold’ ); $pageslist = get_pages( $args ); $pageslist should have all your posts in the “gold” level.

Getting the Featured image URL and inserting it as Custom Field on Post update / publish

The function get_post_thumbnail_id() needs a value to be passed if using outside the wordpress loop. You forgot to pass it. The code you’re using will create a new custom field on each update so here’s the modified code that’ll perform update_post_meta function if that meta_key is already present in database. The bellow code is tested … Read more

Changed PHP handler to DSO – weird custom fields problem [closed]

Take a look at http://halfelf.org/2011/wordpress-dso-and-permissions/ so see if it helps you out. Basically you need to do the following changes: On wp-config.php: define(‘FS_CHMOD_DIR’, (0755 & ~ umask())); define(‘FS_CHMOD_FILE’, (0644 & ~ umask())); To override file permissions. Then if you got your files with 777 permissions you can change them back easily by doing in console: … Read more

List custom field values ​​in alphabetical order without repetition

You could do a custom SQL query: global $wpdb; $query = “SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = ‘director’ ORDER BY meta_value;”; $directors = $wpdb->get_results( $query ); foreach( $directors as $director ) : echo $director->meta_value; endforeach; one thing to note here though is that since you’re not querying the associated posts, you could get … Read more