The code below displays all the images (other than thumbnails) in the article, and if the displayed images exceed 16,
I was going to send a page.
I was planning to send you a page if there are more than 16 images with this code.
If there are 20 images in the article, you have to see all 20 images and not other articles.
They won't send me the page.
How can I solve this problem?
By the way, I referred to this website.
http://kachibito.net/wordpress/custom/stacking-posts-in-a-grid.html
<?php
$num_cols=4;// Number of columns
$paged=(get_query_var('paged'))?get_query_var('paged'):1;// Page Nation
$args = array(
'posts_per_page' = > 16, // Number of posts to display on page 1
'cat' = > 0, // ID of the article category you want to display
'paged' = > $paged
);
query_posts($args);
if(have_posts()):
for($i=1;$i<=$num_cols;$i++):
$counter = $num_cols+1-$i;
while(have_posts())—the_post();
if($counter%$num_cols==0): ?>
<?php$output=preg_match_all('/<img.+?src=[\']([^\']]+)[\"].*?>/i', $post->post_content, $matches);
$all_img = $matches[1];
if(!empty($all_img){
foreach($all_img as $img){?>
<?php echo'<img src="'.$img.'">'?>
<?php
endif;
endwhile;
refresh_posts();
endfor;// Create Page Nation Here
next_posts_link('&lacquo;forward');
previous_posts_link('Go & raquo;');
else:
echo 'no posts';
}
}
endif;wp_reset_query();?>
Simply understand syntax error issues.
if(!empty($all_img)){
foreach($all_img as $img){?>
Because the two blocks that are open in are not closed.
Close each of these blocks with }
before the endif
immediately following them.
© 2024 OneMinuteCode. All rights reserved.