WP_Post is not from correct array

get_the_ID gives you the ID of the current post, but at no point during that loop do you change what the current post is. It’s always the last post processed in the previous loop because that’s the last time you called the_post(). This is why you always get the same ID. Instead, store the ID: … Read more

Loop posts in a table ordered by a custom field value

I found a solution which displays the posts ordered by the date value, and also removes the past ones. <div class=”container”> <div class=”row”> <table> <tr> <th>Artista</th> <th>Fecha</th> <th>Ciudad</th> <th>Información</th> </tr> <?php $today = current_time(‘Ymd’); $args = array( ‘post_type’ => ‘evento’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘-1’, ‘meta_query’ => array( array( ‘key’ => ‘fecha_del_evento’, ‘compare’ => … Read more

Display Taxonomies in loop with template args

The simplest solution: echo get_the_category_list( ‘, ‘ ); Following your way: Change your $args like so: $args = array( ‘template’ => ‘%2$l’, ‘term_template’ => ‘%2$s’, ); And then, add this to your functions.php file (this will affect all %l markers!); add_filter( ‘wp_sprintf_l’, function($templates) { // $templates[‘between_last_two’] = sprintf( __(‘%s, and %s’), ”, ” ); // … Read more

Ajax loop and history.js for SEO

There are some plugins that add the next/prev links in <head> and follow Google recomendations for paginated archives, which are similar to recomendations for infinite scroll. If you are interested in doing it at yor own, you can implement the ajax load-more in archive templates and do something like this (not fully tested, just an … Read more

WP_query for posts with same post type AND same post category

You are using default category for custom post type. You can instead use a taxonomy query to get filtered result based upon your custom taxonomy terms. Try this – $cat_ids = array(); $postID = get_the_ID(); $categories = get_the_terms($postID, ‘custom_taxonomy_name’); //this will give all the terms foreach($categories as $cat) { $cat_ids[] = $cat->term_id; //you may put … Read more