Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKonrad Pilch
2,435 PointsPosts not showing
HI,
So i have created this
//Events
// Our custom post type function
function create_posttype() {
register_post_type( 'events',
// CPT Options
array(
'labels' => array(
'name' => __( 'Events Page' ),
'singular_name' => __( 'event' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'event'),
'menu_icon' => 'dashicons-calendar-alt', // picture on the left [pic]Portfolio
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
And now i have in admin bar 'Events' that are connected with custome fields, and i have three fields, title, image and content.
Now here my loop that i want to display this:
<div class="col-xs-12 col-sm-12 col-md-9">
<div class="row second">
<main class="col-md-12 margin-bottom-20-mobile">
<div class="same-height-1 padding-15 margin-bottom-15">
<?php
$args = array(
'posty_type' => 'events'
);
$the_query = new WP_Query( $args );
?>
<!-- Loop -->
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_post_thumbnail(); ?>
<p><?php the_content(); ?></p>
<br>
<?php endwhile; else : ?>
<h1>Oh no!</h1>
<p>No content is appearing for this page!</p>
<?php endif ?>
</div>
</main><!-- /col-* -->
</div><!-- row second -->
</div><!-- /col-md-9 -->
And this displays my blog posts.. why ..
i have assigned the template name
<?php
/*
Template Name: Events page
*/
?>
And put on my subdomain Events. Its assaigned as template. its pussling my blog posts, why?
1 Answer
Kevin Korte
28,149 PointsFirst thing I noticed is that your argument on your WP_Query class is posty_type, and I believe it should just be post_type
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 Pointsxdd thank you