How to manually define the primary loop

WordPress is not the solution to world hunger, global warming, and not even a good tool to create a one page apps in. If that is what you need, there are probably much better tools that will give you a much better ROI. In theory you can use wordpress as an API, creating an “headless” … Read more

Multisite – Getting Meta query to select from wp_2 tables

From what I understood, you want to get products on US site from UK site. You can use switch_to_blog() to direct your queries to your sub-site. This function uses blog_id as parameter. So, in your case, switch_to_blog(2); //your code to fetch data restore_current_blog(); //this restores query to current sub-site. See documentation: https://developer.wordpress.org/reference/functions/switch_to_blog/

how to call recent post content in a loop ( only the content before read more tag)

for latest 5 post you can use this code: $args = array(‘post_type’=>’post’, ‘posts_per_page’=> 5); $query = new WP_Query($args); if($query->have_posts()): while($query->have_posts()):$query->the_post(); echo ‘<li>’; $content = get_the_excerpt(); //for featured image if(has_post_thumbnail()): the_post_thumbnail(); endif; print $content; echo ‘</li> ‘; endwhile; wp_reset_postdata(); endif; In case you want to change word count in excerpt use this action hook function. /** … Read more

Excerpt isn’t working or am I missing something?

No it’s not. The length limit is for excerpt, which should be called manually. To get the excerpt in your loop, you should use: <p><?php the_excerpt(); ?></p> Instead of: <p><?php the_content(); ?></p> If you thought of this because of the option in the reading section of settings: Then you have to notice, this is for … Read more

How fix error in the WordPress loop?

You’ve set ‘posts_per_page’ => -1,, which means unlimited posts per page, but are checking $wp_query->max_num_pages > 1. There’s never going to be more than 1 page if you have unlimited posts per page.