Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)
CHAPTER 3 • The Loop 45 So what is happening? Well, get_template_part( 'content', 'archive' ) looks for content-archive.php firs ...
46 PART I • Getting Started with WordPress USING THE LOOP Now that you’ve established where you need the loop (in post listings, ...
CHAPTER 3 • The Loop 47 Figure 3-1: All these posts are outputted with the loop. Incidentally, you can make the Read More link a ...
48 PART I • Getting Started with WordPress The second content template tag available is the_excerpt(). As its name implies, it o ...
CHAPTER 3 • The Loop 49 Remember not to use the_excerpt() on templates displaying just one post, such as single. php. You need t ...
50 PART I • Getting Started with WordPress If the post is marked as sticky, post_class() will add a CSS .sticky class. That way, ...
CHAPTER 3 • The Loop 51 Not all themes support sticky posts visually, and the functionality is a bit hidden in the admin interfa ...
52 PART I • Getting Started with WordPress A post published in accordance with the options selected in Figure 3-4 will show up w ...
CHAPTER 3 • The Loop 53 add_theme_support( 'post-formats', array( 'aside', 'gallery', 'video' ) ); } This would add the smashing ...
54 PART I • Getting Started with WordPress Let’s start with looking at how to implement pre_get_posts, which can be done in a nu ...
CHAPTER 3 • The Loop 55 Second, are there any plugins that can do the work for you? The WordPress community is full of brilliant ...
56 PART I • Getting Started with WordPress restore $post to where it was in the original query — something that might be what yo ...
CHAPTER 3 • The Loop 57 Recall the query_posts() template tag. The usage description says that it is intended to modify the main ...
58 PART I • Getting Started with WordPress The actual output of the loop’s content isn’t covered in this example. It can be anyt ...
CHAPTER 3 • The Loop 59 <?php // Featured loop ends endwhile; // Resetting wp_reset_postdata(); ?> This is very similar t ...
60 PART I • Getting Started with WordPress This is pretty much the same as the first loop but limited to showing ten posts from ...
CHAPTER 3 • The Loop 61 // Our query and loop $apple_query = new WP_Query( $args ); while ( $apple_query->have_posts() ) : $a ...
62 PART I • Getting Started with WordPress // Resetting wp_reset_postdata(); ?> </ul> </div> <div class="colum ...
CHAPTER 3 • The Loop 63 lot of plugins and template tags that you will want to use have to reside inside the loop makes it impor ...
...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf