Loop inside the loop

I would use get_posts() for your two ad hoc Loops. (Actually, you only need one ad hoc Loop, if you’re modifying the main Loop so that only 2 posts are retrieved.) e.g. \\ code modify main Loop to return only 2 posts goes here $firstpost = true; if ( have_posts() ) : while ( have_posts() … Read more

Loop through child images of a parent for a Nivo Slider

To get attached (i.e. child) images of a post, try using get_children(). e.g.: <?php $child_image_args = array( ‘post_mime_type’ => ‘image’, ‘post_parent’ => $postID, ‘post_type’ => ‘attachment’ ); $child_images = get_children( $child_image_args ); ?> Which returns an associative array of child images. Then, just loop through them, e.g. using wp_get_attachment_image(), to output. e.g.: <div id=”nivoslider”> <?php … Read more

This AJAX Code Doesn’t Work – Looking for elegant solution

Working Code Based On My Previous Answer Without using nonce.. but you can check the previous answer on how you can implement a nonce check. And the code is based on your code. misha_my_load_more_scripts() in functions.php function misha_my_load_more_scripts() { wp_register_script( ‘my_loadmore’, get_stylesheet_directory_uri() . ‘/js/myloadmore.js’, array( ‘jquery’ ), ”, true ); wp_enqueue_script( ‘my_loadmore’ ); } add_action( … Read more

Where should I use post_class()?

It’s actually only important to use it if your theme’s CSS or JS is reliant on something it outputs. It essentially stuffs relevant class names into the HTML tag you put it on based on the current post/category/blah/blah. So, on a single post template this: <article <?php post_class(); ?>> might output: <article class=”post post-123 category-3 … Read more