Getting selection of posts based on loop variables via Ajax

You can easily add whatever variables you want to your AJAX call. Using jQuery you can set a AJAX action like this: jQuery.post( ‘your-url-to-admin-ajax.php’, { action: ‘your_called_function’, argument: ‘year’ or ‘category’, some_other_var: ‘some value’ }, function( response ) { if(response) { } else { } } ); Then in your functions.php add this: add_action( ‘wp_ajax_nopriv_your_called_function’, … Read more

Query post & loop problem.

no idea what the problems actually are, but from looking at the code, I woud suggest: a: the while (have_posts()) : should be while ($the_query->have_posts()) : b: you would need to increment the counter: <?php $count = $count + 1; ?> c: the endif; of the loop might be missing after the endwhile; – at … Read more

Using jQuery .after inside loop

WordPress requires no-conflict for jQuery. Change this: var tiles = $(‘#article-tile:nth-child(‘+adLoc+’)’); $(tiles).after(adTile); …to this: var tiles = jQuery(‘#article-tile:nth-child(‘+adLoc+’)’); jQuery(tiles).after(adTile); Or else wrap your entire script accordingly: jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function });

Exclude posts based on an array

You’re looking for post__in & post__not_in parameters http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters Both of them are an array of ID’s for the post’s to include or exclude in the results BTW in your code, you had a semicolon just after your foreach

Multiple loops for plugin

I’ve managed to do it by setting the post type when I make the query $my_query = new WP_Query( array(“post_type” => “tcp_product”)); if ( $my_query->have_posts() ) { while ( $my_query->have_posts() ) { $my_query->the_post(); the_title(); } } wp_reset_postdata();