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

I have broke my pagination, same posts on all pages (index.php)

I seem to have fixed the pagination issue with the custom loops, not entirely sure how it works, but it does seem to work. I have changed the custom loop to the following; <?php $paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1; $the_query = new WP_Query( array( ‘post__not_in’ => get_option( ‘sticky_posts’ ), ‘posts_per_page’ => … Read more

Get the image src and href data from posts

You can use preg_match_all to perform a regular expression match on the content of the post. <div id=’hitstatAdminMain’> <?php $args = array(‘post_type’ => ‘post’, ‘posts_per_page’ => -1); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()){ $query->the_post(); // Store the current iterated posts content in a variable $content = get_the_content(); // Perform a global regular … Read more

Grabbed Post ID under WP loop, but still couldn’t Print Post title

Since you’re in a Loop, you don’t need to grab the post ID or use get_the_title(). Instead, replace line 2 and 3 of your code with: the_title(‘<h1>’, ‘</h1>’); Or, if you want to include a link as well: <h1><a href=”https://wordpress.stackexchange.com/questions/272948/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1>

How to get pagination to work with 2 wordpress loops

So you have a big problem here and a pack of small problems. The big one is — pagination cannot be reliably changed within template. It just doesn’t work like that. Pagination and main query are processed before template is ever reached. So I would guess information you are coming upon is about the need … Read more

Getting page slug

If you are inside the loop, you don’t need to access global $post, you already have $post variable accessible in your local scope, and this variable holds the data from current loop iteration. If you are outside the loop, then you need to access global $post first, and it will hold whatever data it was … Read more

using wp_get_attachment_image_src in foreach loop

First in your first loop why do you break it? if there is no image in image_5 if someone just skip this and continue to image_6? Second the ACF image field can return you an array with all the sizes. you need to set the field to return you Image Array And then you can … Read more