Shortcode with custom image field?
-
Hi
I cannot get the image from one of my fields into a shortcode.
(it works with get_the_post_thumbnail($post->ID, ‘thumbnail’) But i need the value from the field “udstiller logo”Here is my code
function logo_shortcode( $atts ) { extract( shortcode_atts( array( 'limit' => '50', 'orderby' => 'name', ), $atts ) ); // Creating custom query to fetch the project type custom post. $loop = new WP_Query(array('post_type' => 'udstillere', 'posts_per_page' => $limit, 'orderby' => $orderby)); $output = '<ul class="bxslider">'; // Looping through the posts and building the HTML structure. if($loop){ while ($loop->have_posts()){ $loop->the_post(); $output .= '<li><a href="'.get_permalink().'"><img src="'.get_post_meta($post->ID,'wpcf-udstiller-logo',true).'"/></a></li>'; } } else $output = 'Sorry, No projects yet. Come back Soon.'; // Now we are returning the HTML code back to the place from where the shortcode was called. return $output; $output = '</ul>'; } add_shortcode("Logo", "logo_shortcode");
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Shortcode with custom image field?’ is closed to new replies.