Like the blog? Get the book »

Posts tagged: loop

Archive page 1 of 1
Display Blog Posts on any Page (with navigation)

Display Blog Posts on any Page (with navigation)

By default, your latest WordPress posts are displayed on the home page, with older posts available via post navigation on /page/2/, /page/3/, and so on. In this DigWP post, we’ll explain how to display your blog posts on any static page using a custom WP_Query loop that works beautifully with post navigation.

3 Ways to Reset the WordPress Loop

3 Ways to Reset the WordPress Loop

WordPress does an excellent job of keeping track of what’s happening with the loop, but once you start customizing parameters and setting up multiple loops, it’s a good idea to explicitly reset them using one of three WordPress template tags. In this DigWP post, we’ll explore each of these three loop-reset techniques to get a better understanding of when and how to use them in your WordPress themes.

4+ Ways to Loop with WordPress

4+ Ways to Loop with WordPress

At the heart of the WordPress theme template is the venerable WordPress loop. When you’re looking at your index.php file, for example, the loop is the part that typically begins with if(have_posts()) and contains all the tags and markup used to generate the page. The default loop works perfectly well for most single-loop themes, but for more advanced designs with stuff like multiple and custom loops, more looping power is needed. Fortunately, WordPress provides plenty of flexibility with four or five ways to loop:

Thumbnail Based Archives

Thumbnail Based Archives

Here at Digging Into WordPress, we’ve attached thumbnail images to every single (non-link-style) post since day one. We started before WordPress 3.0 had the specific feature for thumbnails. We did it just by attaching a file path to the thumbnail image as a custom field. We clearly display each of those thumbnails in the design of the homepage and other various pages where it makes sense.

6 Ways to Display WordPress Post Content in Multiple Columns

6 Ways to Display WordPress Post Content in Multiple Columns

Most blogs display their post content in single columns, like what we do here at Digging Into WordPress. But you know it’s also possible to display post content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. This DigWP article presents six ways of getting the job done using a variety of techniques, tricks, and tips.

Custom Query Shortcode: Run a Loop inside Any Post/Page

Custom Query Shortcode: Run a Loop inside Any Post/Page

I had the occasion yesterday to have a page with a section on it where it would output a very specific set of other pages, which would need to change dynamically. What I could have done is built a special page template for this page, and inside that template run a query_posts() to get these posts. But I wanted this page to remain editable from the admin. Besides, creating a special page template every time you need to do something like this is too cumbersome. WordPress is extensible enough to do better.

Two Ways to Limit the Number of Posts without a Plugin

Two Ways to Limit the Number of Posts without a Plugin

Let’s say your blog is set to display ten posts per page, as specified via the WordPress Admin under Settings ▸ Reading. Once set, ten posts will appear on your home page, archive pages, search results, and so on. In other words, if it isn’t a single-view page or an actual “page” page, you’re gonna get ten posts per page. It’s a global setting.

But what if you want to display different numbers of posts for different types of page views? For example, instead of showing just ten posts on your search-results pages, you may want to show a whole bunch, like maybe fifty or something. Perhaps you would also like to limit the number of posts displayed on your category archives to only five.

Easy Custom Feeds in WordPress

Easy Custom Feeds in WordPress

Now that we have seen how to setup Tumblr-style posts, it would be nice to be able to segregate the Tumblr-posts category from the main feed into its own, separate feed. This would enable readers to subscribe exclusively to the Tumblr-posts feed and maybe display it in their sidebar or something.

Create a Stunning Lightbox-Style Random-Post Header Gallery

Create a Stunning Lightbox-Style Random-Post Header Gallery

In this tutorial, we’re going to take advantage of two of WordPress’ most powerful features, get_posts() and custom fields, to create a stunning random lightbox-style header gallery for your post images.

Displayed before the standard post loop, this lightbox gallery will randomly display the images that are associated with your posts while also providing a descriptive title link to the post itself. Here is a graphical representation that will help us visualize the concept:

© 2009–2024 Digging Into WordPress Powered by WordPress Monzilla Media shapeSpace