Display Page featured Image as well as Posts featured Image

WordPress loop functions depend on the global variables, so you will have to get the data from page before you run the loop. Generally, you should be able to do something like this- $page_id = get_the_ID(); //this is important, we will use this later while(have_posts()): the_post(); //do something with the post here echo get_the_post_thumbnail( $page_id … Read more

Wrap every 2 divs in row – for each loop [closed]

You need to create a variable with the count and then check against it e.g. $num = 1; foreach ( $terms as $term ) { if($num%2) { echo ‘<div class=”something”>’; } // other stuff if($num %2) { echo ‘</div>’; } $num++ } The %2 is the part you need, it checks whether the number is … Read more

Wrap every 2 posts

You need to start Row class after every 2N+1 post. And end the Row class after every 2N+2 Post. Try this one <?php $counter++; if ($counter % 2 == 1) : ?> <?php echo ‘<div class=”post-wrapper”>’; ?> <?php endif; ?> <?php get_template_part( ‘templates/blog/blog-2-cols’, get_post_format() );?> <?php $counter++; if ($counter % 2 == 0) : ?> … Read more

Different style for first two (sticky) posts

I think you should add a css class and in your loop, put a $i and let $i run, if $i == 2 then you add the css class attribute to that sticky post. $i = 0; while( have_posts() ): the_post(); $i++; if($i == 2): $css_class=”top-sticky”; else: $css_class=””; endif; endwhile; wp_reset_postdata();

First post in loop displays twice

The else of the $change % 5 == 0 also runs when $change is a 1 and that is why the first post is displayed twice. You could fix it by changing <?php $change++ ?> <?php endif; ?> <?php if ( $change % 5 == 0 ) : ?> to <?php $change++ ?> <?php elseif … Read more

Pagination in category.php not functioning

if your aim is to restrict the category archive to your post_type ‘video’ and to 6 posts per page, do not edit category.php, rather use ‘pre_get_posts’ https://developer.wordpress.org/reference/hooks/pre_get_posts/ example code for your case: add_action( ‘pre_get_posts’, ‘category_post_type_video_custom’ ); function category_post_type_video_custom( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)