Link the retrieved custom field values to its respective posts

You achieve this by modifying your code as following and using get_results function instead of get_col function. <?php function get_meta_values( $key = ”, $type=”post”, $status=”publish” ) { global $wpdb; if( empty( $key ) ) return; $r = $wpdb->get_results( $wpdb->prepare( ” SELECT pm.meta_value, p.ID FROM {$wpdb->postmeta} pm LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id WHERE … Read more

Read more to open external link

You just need to add target=”_blank” to the anchor tag. function remove_more_link_scroll( $link ) { $link = str_replace(‘>’,’ target=”_blank”>’, $link); return $link; } add_filter( ‘the_content_more_link’, ‘remove_more_link_scroll’ ); I feel compelled to state that I consider forcing new tabs/windows to be very unfriendly behavior, and if you search the web you will see that I am … Read more

How to I make my post title link to a custom field

I assume that the post title markup looks something like so: <h1><a href=”https://wordpress.stackexchange.com/questions/117332/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> You merely need to replace <?php the_permalink(); ?> with your post custom meta value: <?php $post_bookmark = get_post_meta( get_the_ID(), ‘post_bookmark_url’, true ); ?> <h1><a href=”https://wordpress.stackexchange.com/questions/117332/<?php echo $post_bookarmk; ?>”><?php the_title(); ?></a></h1> Other caveats: You’ll want to consider the context … Read more

Custom Field – Do Not Show if Value is Empty?

Add a little check to your code function custom_do_grid_loop() { // Intro Text (from page content) echo ‘<div class=”page hentry entry”>’; echo ‘<h1 class=”entry-title”>’. get_the_title() .'</h1>’; if ( has_post_thumbnail() ) { echo ‘<div class=”import-image”>’ . get_the_post_thumbnail() . ‘</div>’; } echo ‘<div class=”entry-content”><p>’ . get_the_content() . ‘</p>’; //Add this condition to your code $meta = genesis_get_custom_field( … Read more

Can I use a Custom Field as the Featured Image URL?

Editing the Template The easiest solution would be to use a conditional to display the featured image: if has custom field use it, else use Featured Image You can get the custom field using get_post_meta(), which will return an empty string if the specified key isn’t set: $custom_url = get_post_meta( get_the_ID(), ‘old_featured_image_custom_field’, true ); You … Read more

Echo the custom field value from the latest post from the ‘video’ post format?

While this may not answer your question, but it will be helpful to solve it. It seems like the statement $video = get_post_meta($postid, ‘dt_video’, true); is assigning blank string value to $video variable and thus iframe code becomes <iframe width=”180″ height=”101″ src=”https://wordpress.stackexchange.com/questions/139255/?rel=0″ frameborder=”0″ allowfullscreen></iframe> which is the cause of your site being displayed in the … Read more