What PHP Needed to Make One Loop with Multiple Styling?

this is your answer… however like Kaiser said, you should really take some time to read a little… <?php $i=0; if ( have_posts() ) while ( have_posts() ) : the_post(); if($i==0) { ?> // YOUR FIRST POST CONTENT } else if(($i==1) || ($i==2) || ($i==3)) { // POST 2, 3, 4 } else { // … Read more

How to Loop with the final result formatted differently?

I’m not sure of the context for this, but query_posts probably isn’t what you want to use. (See this answer). (Untested). I would use get_posts: $posts = get_posts(array( ‘numberposts’=>-1, ‘category’=>0 )); And then use wp_list_pluck to get the titles: $post_titles = wp_list_pluck($posts,’post_title’); $post_titles = array_map(‘esc_html’,$post_titles); Finally, the php implode function an list them with commas: … Read more

how to replace get_template_part(‘loop’,’tag’) with explicit styled version?

I think you misunderstand the purpose of get_template_part(). It is a wrapper for locate_template(), which itself is just a wrapper for include(). By calling get_template_part( ‘loop’, ‘tag’ ), you are telling WordPress to look for/include a file based on the following priority: Child Theme loop-tag.php Parent Theme loop-tag.php Child Theme loop.php Parent Theme loop.php If … Read more

How do I get my loop.php to properly paginate?

I don’t know what’s inside featured-content-slider.php, but I’m assuming this is the loop you’d like to paginate: query_posts(‘category_name=featured-news’); The issue is that by calling query_posts like this in the template, you’re overwriting the original query for the page and not setting any page parameter. Your two options are to either modify the original query string, … Read more

How do I display the latest posts from three different categories?

Don’t use query_posts – it’s can really mess things up. Instead, use three WP_Query instances: $post_from_cat_a = new WP_Query(array( ‘category__name’ => array(‘a’), //Get posts from category a ‘posts_per_page’=> 1 //Limit it to the latest one )); if( $post_from_cat_a->have_posts() ){ while( $post_from_cat_a->have_posts() ): $post_from_cat_a->the_post(); //Display output here for post from category a endwhile; } $post_from_cat_b = … Read more

custom post on homepage

You can also use a new query (with php enabled) so show a single post by ID, i.e. the post with ID 101: <?php $my_query = new WP_Query(‘p=101’); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/64210/<?php the_permalink() ?>” title=”<?php the_title(); ?>”> <?php the_title(); ?><?php the_content(); ?></a> <?php endwhile; ?> This can be used multiple … Read more

New loop vs widget

You should always use widgets when you need to add any kind of content to the sidebar. The reason is very practical – once the project is over the owner of the site will not need to contact you just because he wants to put a banner before your “loop”, and even during development it … Read more

Contact information footer

Another option is to create a new post type called “modules” or something to that effect. Then you can create as many of those as you like, for example, “Footer: Contact Information,” “Footer: Social Media,” “Header: Callout,” etc, and you can use that post’s ID to bring it into the designated spots in your template. … Read more