• Hi
    I’m sitting on a private Project where I need to display all terms of a tax and the Post marked with each tax.

    I’ve done this so far:

    function srview_func ($atts) {
    	$output = '';
        $terms = get_terms( 'klasse', 'orderby=slug&hide_empty=0&order=DESC' );
        foreach($terms as $term){
    		$output .= '<h3>' . $term->name . '</h3>';
    
    		$zposts = new WP_Query(array(
    		'post_type' 		=> 'my_custom_posttype',
    		'posts_per_page' 	=> -1,
    		'klasse'		=> $term,
    		'meta_key'		=> 'timestamp',
    		'orderby'		=> 'meta_value_num',
    		'order'			=> 'ASC',
    		)
    		);
    		if ( $zposts -> have_posts() ) {
    			while ( $zposts -> have_posts() ) {
    			$zposts -> the_post();
    			$output .= '<img src='. get_post_meta(get_the_id(), 'meta-image', true) .'" alt="' . get_post_meta(get_the_id(), 'NameInput') . '">';
    			}
    		}
        }
    	return $output;
    }

    The Terms are displayed as planned, but the Posts(the images) are missing and don’t show up.
    Did I do something wrong?

    Thanks for help!
    ~Windy

Viewing 1 replies (of 1 total)
  • Chad

    (@lynneandchad)

    Not sure if this is what’s actually causing the problem, but I think you’re missing an opening quote around your source:

    function srview_func ($atts) {
    	$output = '';
        $terms = get_terms( 'klasse', 'orderby=slug&hide_empty=0&order=DESC' );
        foreach($terms as $term){
    		$output .= '<h3>' . $term->name . '</h3>';
    
    		$zposts = new WP_Query(array(
    		'post_type' 		=> 'my_custom_posttype',
    		'posts_per_page' 	=> -1,
    		'klasse'		=> $term,
    		'meta_key'		=> 'timestamp',
    		'orderby'		=> 'meta_value_num',
    		'order'			=> 'ASC',
    		)
    		);
    		if ( $zposts -> have_posts() ) {
    			while ( $zposts -> have_posts() ) {
    			$zposts -> the_post();
    			$output .= '<img src="'. get_post_meta(get_the_id(), 'meta-image', true) .'" alt="' . get_post_meta(get_the_id(), 'NameInput') . '">';
    			}
    		}
        }
    	return $output;
    }

    PS and no, you’re not dumb ??

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Query – Problem with Output. Am I Dumb? ;-)’ is closed to new replies.