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 });

How to repeat a loop after 4 posts [duplicate]

Assuming that you’re only using the counter to decide what style to use, the easiest way to achieve what you want would be to reset the $count variable once it gets to 4. <?php elseif ($count == 4) : ?> <div>Styled post 4</div> <?php $count = 0; ?> <?php else : ?>

CPT archive page – show one post from each taxonomy term

So I went ahead and did the multiple loop thing, as I had done before. I’m always interested in seemingly cleaner/simpler solutions, but sometimes you just have to keep moving. This is the code I’m using: <?php $args = array( ‘post_type’ => ‘projects’, ‘project_category’ => ‘websites’, ‘orderby’ => ‘menu_order’, ‘showposts’ => 1 ); $posts = … Read more

posts going to 2 pages/categories only show up in 1

First thing : you should not use category ids directly. Use slugs instead : it’s easier to maintain. <?php query_posts(‘category_name=portfolio’); ?> Second thing : why did you put a query parameter in the_post ? This function does not accept any parameter (see the Codex). Third thing : the call to query_posts(‘cat=-4’); will show all posts … Read more

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();