Created
March 1, 2017 20:51
-
-
Save iamlucianojr/7fe2c06189bfc2d7e3023deb67acfd72 to your computer and use it in GitHub Desktop.
How to list custom post type and custom fields on WP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Event list | |
*/ | |
get_header(); | |
?> | |
<div id="primary" class="content-area"> | |
<main id="main" class="site-main" role="main"> | |
<?php | |
$args = array( 'post_type' => 'event', 'posts_per_page' => 10 ); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
the_title(); | |
echo the_meta(); | |
echo '<div class="entry-content">'; | |
$name = get_post_meta(get_the_ID(), 'wpcf-name'); | |
var_dump($name[0]); | |
the_content(); | |
echo '</div>'; | |
endwhile; | |
?> | |
</main><!-- #main --> | |
</div><!-- #primary --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment