Multiple loops in same page, without duplicate content

it is important to read this Codex chapter all the way to the end, as the essential suggestions are after this heading ‘Note for Multiple Posts in the First Category’; repetitive, tedious code: <?php $do_not_duplicate = array(); ?> <?php $mosaics = new WP_Query(‘category_name=mosaics&posts_per_page=5’); ?> <?php while ($mosaics->have_posts()) : $mosaics->the_post(); ?> <?php $do_not_duplicate[] = $post->ID; ?> … Read more

Show a list of recently viewed posts to a user

This plugin may fulfill your requirements. http://wordpress.org/extend/plugins/recently-viewed-posts Usage get_recently_viewed_posts( $max_shown = 10 ) returns a string of li’s. recently_viewed_posts( $max_shown = 10 ) prints a div If you are interested in learning how to develop this functionality yourself, download the plugin and see the source files. WordPress is Open Source! Update: The above plugin did … Read more

loop not showing up when using a custom page template

You haven’t created a query to return your post index results. Let me back up… In WordPress something called the “Main” query runs very early in the page load, and well before your template files load. That query retrieves the posts to display and also (more or less) determines which template file to use to … Read more

Displaying child page content of a certain parent

This is a near duplicate of a number of questions here, but the “single random result” might make it somewhat distinct. $args = array( ‘post_type’ => ‘page’, ‘post_parent’ => $post->ID, ‘orderby’ => ‘rand’, ‘posts_per_page’ => 1, ‘no_found_rows’ => true ); $child = new WP_Query($args); var_dump($child->posts); You are telling WP_Query to pick 1) pages, 2) with … Read more

How to display the rest of categories on Portfolio filterable

if your terms and their slugs are: red, blue, green, yellow. <div data-tag=”<?php echo $terms_portfolio[0]->slug; ?>” would output only the first <div data-tag=”red” if you do <?php $terms_portfolio_slugs = array(); foreach ($terms_portfolio as $tp) { $terms_portfolio_slugs[] = $tp->slug; } $terms_portfolio_csv = implode (‘, ‘,$portfoliotags); ?> <div data-tag=”<?php echo $terms_portfolio_csv?>”> your output would be all of … Read more