Custom wordpress loop

You can set your custom loop something like this $a=2; //In while loop counter increments by one $counter++ if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); if($a%3!=0){ //Here write function to display title and discription ?> <div class=”col-md-4 col-sm-6″> <div class=”cp-attorneys-style-2″> <div class=”frame”> <a href=”https://wordpress.stackexchange.com/questions/263067/<?php the_permalink(); ?>”><?php the_post_thumbnail(”); ?></a> <div class=”caption”> <div class=”holder”> <ul> … Read more

Querying another post category to match current post and display in loop

if you are adding the custom query into the single template, try working with get_the_category() to get the cat_id for your query; also, get_posts() does not work with if( have_posts() ) etc. example code, using a custom query: <?php $cat = get_the_category(); $cat_id = $cat[0]->term_ID; $cpt_match_query = new WP_Query( array( ‘posts_per_page’ => 2, ‘post_type’ => … Read more

Get post format

If you’re outside the loop, pass a post ID. $format = get_post_format( $post_id ); To guard against missing formats, add a default to your template: $format = get_post_format() ? : ‘standard’; Then you can use your same IF statement: if ( $format == ‘link’ ) :

get_template_part() Not Working in Loop

Thinking about my comment…wouldn’t it be simplier to say: <section id=”content” class=”site-content blog-page”> <div class=”container”> <?php if ( is_home() || ( is_front_page() && is_home() ) ) : ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2> There are posts but template parts aren’t found </h2> <?php get_template_part( ‘template-parts/post/content’, get_post_format() ); ?> <?php get_template_part( … Read more

Twenty Seventeen Pages Loop

The page selection is set within the Customizer under Theme Options, which will only show when front page is set to static. The output happens within the function twentyseventeen_front_page_section in the theme file template-tags.php, where each panel is queried individually with get_post, so it’s not exactly a loop in the conventional sense. You can change … Read more

ul list with only as many li’s as filled custom fields

You could add a check to only display the item if it exists: <?php if ( $imagen4 ) { ?> <li class=”artiq-slidder-item”> <img src=”https://wordpress.stackexchange.com/questions/269610/<?php echo $imagen4[“url’] ?>”></li> <?php } ?> But it looks like you are using the Advanced Custom Fields plugin. If this is the case, you would probably be better off using a … Read more