• Resolved rilana

    (@rilana)


    Hi

    I know this should be simple, but somehow I cant figure it out. I have a Custom Post Type with custom Fields in a separate Template in my Theme. It goes like this:

    <?php
        <?php if(function_exists('mpdf_pdfbutton')) mpdf_pdfbutton(); ?>        
    
        $mypost = array( 'post_type' => 'appartement',
        'posts_per_page'	=> -1,
    	'meta_key'		=> 'haus-nr',
    	'orderby'		=> 'meta_value_num',
    	'order'			=> 'ASC'
        );
    
        $loop = new WP_Query( $mypost );
    
        ?>
    
        <?php while ( $loop->have_posts() ) : $loop->the_post();  ?>
    
    <?php echo get_post_meta( get_the_ID(), 'appartement-nr', true); ?>
    
    <?php endwhile; ?>

    So I tried making a new PDF Template but I cant figure out how to show these custom Fields of my custom Post types. I tried this.

    $mypost = array( 'post_type' => 'appartement',
    	    'posts_per_page'	=> -1,
    		'meta_key'		=> 'haus-nr',
    		'orderby'		=> 'meta_value_num',
    		'order'			=> 'ASC'
        );
    
        $loop = new WP_Query( $mypost );
    
        while ( $loop->have_posts() ) : $loop->the_post();
    
        	$pdf_output .= 'get_post_meta($post->ID, 'appartement-nr', true)';
    
    	endwhile; 
    
    		$pdf_output .= '</div> <!--content-->';

    I would really appreciate any help. Thanks, Rilana

    https://wordpress.org/plugins/wp-mpdf/

Viewing 1 replies (of 1 total)
  • Plugin Author fkrauthan

    (@fkrauthan)

    $pdf_output .= 'get_post_meta($post->ID, 'appartement-nr', true)';

    should be

    $pdf_output .= get_post_meta($post->ID, 'appartement-nr', true);

    Does that work for you?

Viewing 1 replies (of 1 total)
  • The topic ‘How to export a list of Custom Fields from Custom Post Types’ is closed to new replies.