Get single image from custom fields made with WCK custom fields creator

Here is the code that worked. I had to get rid of the foreach loop and reference the array directly: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $productimgs = get_post_meta( $post->ID, ‘productimg’, true ); $image_color = $productimgs[0][‘product-image-color’]; $image_bw = $productimgs[0][‘product-image-bw’]; $imgclr = wp_get_attachment_image_src( $image_color, ‘grid-large’ ); $imgbw = wp_get_attachment_image_src( $image_bw, … Read more

unlink() doesn’t delete the uploaded file

I figured it out! the problem is the path is not right! Thanks to this post : Alow users to delete uploaded images inside backend? this function below helped : function url_to_path_test($url){ $url=str_replace(rtrim(get_site_url(),”https://wordpress.stackexchange.com/”).”https://wordpress.stackexchange.com/”, ABSPATH, $url); return $url; } So in my code if you change the remove previous image like this it will work : … Read more

Display custom field outside the loop

<?php define(‘WP_USE_THEMES’, false); require(‘wp-blog-header.php’); ?> <?php $post_id = 288; echo get_post_meta($post_id, ‘caption’, true); ?> That part is enough – are you sure that this is the name of your custom field and the path to wp-blog-header is resolved and valid?

get adjacent post by meta key and meta value

The plugin “Ambrosite Next/Previous Post Link Plus” https://wordpress.org/plugins/ambrosite-nextprevious-post-link-plus/ ..seems to do the job well To further style the results, one could even use it like this $prev = previous_post_link_plus( array(‘return’ => ‘id’) ); query_posts(‘p=’.$prev); while (have_posts()) : the_post(); […your stuff here…] endwhile; wp_reset_query(); $next = next_post_link_plus( array(‘return’ => ‘id’) ); query_posts(‘p=’.$next); while (have_posts()) : the_post(); … Read more