Only show image from custom field when present

<?php $imageid = get_post_meta($post->ID, ‘imageembed’, true); if($imageid != ”) { ?> <div class=”newsimage”><img src=”https://wordpress.stackexchange.com/questions/57967/<?php echo wp_get_attachment_url( $imageid ); ?>” width=”640″ /></div> <?php } ?> Use if condition to check if $imageid has any value in it or not.

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

Adding class to last list item? Not WP generated

I can only see achieving this by first building an array, then looping over it – I can’t find anything in APC’s docs about checking if it’s the last iteration of the_repeater_field: $images = array(); while ( the_repeater_field( ‘homepage_service’ ) ) $images[] = get_sub_field( ‘service_image’ ); if ( $images ) { $image_last = array_pop( $images … 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

Copy/clone/associate Custom field to Custom Taxonomy

Here is a simple plugin with the convert function from the plugin you linked and a simple WordPress cron setup to run daily just make sure you change CUSTOM_FIELD_KEY and TAXONOMY_NAME to the actual values <?php /* Plugin Name: wpse62432 Plugin URI: http://en.bainternet.info Description: Answer to http://wordpress.stackexchange.com/questions/62432/copy-clone-associate-custom-field-to-custom-taxonomy Version: 1.0 Author: bainternet Author URI: http://en.bainternet.info */ … 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