Using page template to fetch posts in page

You will want to use wp_query to query the database for the posts, which will be something like: <?php $blog_args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’ ); $blog_query = new WP_Query($blog_args); while ( $blog_query->have_posts() ) { $blog_query->the_post(); echo ‘<a href=”‘.get_permalink().'”>’.get_the_title().'</a>’; } wp_reset_postdata(); ?> That will display all posts with just … Read more

the_content() keeps repeating itself

Solved. This was due to reveal using an ID (see myModal ID) and iterating the same ID over and over again. As a fix, I used: id=”modal-<?php echo get_the_ID(); ?>” This has solved my issue of the_content() repeating its first iteration over and over.

custom post type loop

There may be cleaner ways to do it, but I think this will work: <?php $args = array(‘post_type’ => ‘music-playlist’); $query = new WP_Query($args); $cntr = 0; while( $query -> have_posts() ) : $query -> the_post(); $cntr++; ?> <section class=”row-wrap”> <div class=”row-inner”> <?php if ($cntr % 2 == 1) { // first or third items, … Read more

List active taxonomy terms

Well I did it.. <ul id=”filter”> <li><a href=”#” class=”current” data-filter=”*” title=””>*</a></li> <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?> <?php $term_id = $term->term_id; $taxonomy_name=”categories”; $termchildren = get_term_children( $term_id, $taxonomy_name ); foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li><a href=”#” data-filter=”.’ . $term->slug … Read more

Repeat code, change variable?

So you basically don’t want to keep repeating the same HTML over and over. You should put all of the tags and categories you want to display into an array. Then iterate over that array, querying and printing HTML each time. You could use conditionals to display different HTML where necessary. $terms = array( array( … Read more

Page gets displayed in post field

It looks like you are attempting to create a secondary archive/index page on the “events” template, but haven’t modified the main query for the page. Without that, you will only get results for the one page. Try: function events_wpse_206465($qry) { if (is_page(‘events’) && is_main_query()) { $qry->set(‘posts_per_page’,5); $qry->set(‘post_type’,’events’); } } add_action(‘pre_get_posts’,’events_wpse_206465′); Or create a new query: … Read more

Post are not showing up

The reason is that its not showing up <?php if ( has_post_thumbnail() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/206672/<?php the_permalink(); ?>”> <?php the_post_thumbnail(); ?> </a> <?php endif; ?> You are displaying just a link with check that is featured image exists or not It seems, your post doesn’t have featured image, select any featured image or just … Read more