WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
Shortcode with custom image field? (2 posts)

  1. zebrastribe
    Member
    Posted 1 year ago #

    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");

    http://wordpress.org/extend/plugins/types/

  2. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.