Custom Loop Pagination on WordPress

Edit So, the reason that this isn’t working is because you’ve modified the question to specify that this is happening in a custom page template. Since this is the case, you’ll need to use two separate custom queries, and won’t need to bother with filtering the main query via pre_get_posts. The first query will be … Read more

WordPress – thumbnail image from youtube (function and loop)

Well, assuming the post content will be provided by Youtube embedded code, a change in the regular expression is needed. The function must obtain the source of the iframe. So would be as follows: function get_thumbnail_fromyoutube( $size = 0 ) { global $post, $posts; $youtube=””; $get_url = preg_match_all(‘/src=”https://wordpress.stackexchange.com/questions/151570/([^”]+)”https://wordpress.stackexchange.com/”, $post->post_content, $matches); $youtube = $matches[1][0]; var_dump($youtube); if(preg_match(‘/^(http:\/\/www.youtube.com)/’, … Read more

pop-up lighbox with AJAX

To use AJAX in a WordPress website you can the admin-ajax.php file. This file handles your requests and sends it to the correct function. A short step-by-step guide on how to achieve: First you need to localize your javascript file so that it knows the URL of the admin-ajax.php file on your server. add_action( ‘wp_enqueue_scripts’, … Read more

Trying to list out child pages with WP_Query

I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you while() statement you have the_post(). This doesn’t work in secondary queries, it should look like: <?php if( $subpages->have_posts() ) : ?> <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?> … <?php … Read more

Loop through two different sets of custom fields

Your question literally doesn’t quite sound like “combining” loops, that’s usually different thing in WP terminology. Following it literally you already know the part that outputs artist name you want — the_field(‘artist_name’). What probably confuses it in first context is that it’s not really a normal WP loop. Note how that call doesn’t specify which … Read more

WP_Query post at custom position

Pagination should be easy. You really just need to add pagination parameters to your query, and next/previous posts links, more or less like in another thread I posted in recently. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $my_query = new WP_Query( array( ‘showposts’=>10, ‘paged’ => $paged ) ); // run the loop then, // pagination … Read more

include(locate_template) messing up the loop

I found the problem here. It was with the $this_page variable, it was referencing the homepage still and kept the about page from working. I had to simply modify how it was pulling the page ID and storing it. Here’s my amended code. <?php /* Template Name: Page- Home */ get_header(); ?> <?php $this_page=get_the_ID(); $loop … Read more