Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How about you do something like this:</p> <p>blog-template.php:</p> <pre><code>&lt;?php/* Template Name: Blog Page */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php get_template_part( 'layout-page', 'blog' );?&gt; &lt;?php get_footer(); ?&gt; </code></pre> <p>layout-page-blog.php:</p> <pre><code>&lt;?php the_post(); $title = get_the_title(); $baselink = get_permalink(); $category = get_field('category_blog'); if( !empty($category) ){ $post_per_page = get_option('posts_per_page'); $paged = (get_query_var('page')) ? get_query_var('page') : 1; $categoryID = get_category_id($category); $total = get_post_count(array($categoryID)); $the_query = new WP_Query("posts_per_page={$post_per_page}&amp;cat= {$categoryID}&amp;paged={$paged}"); ?&gt; &lt;div id="wrapper"&gt; &lt;div id="content"&gt; &lt;h1 class="title"&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt; &lt;div class="content-middle"&gt; &lt;div class="node"&gt; &lt;?php while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); ?&gt; &lt;h3&gt;&lt;a href="&lt;?php echo get_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt; &lt;div class="content"&gt; &lt;?php echo content(150); ?&gt; &lt;/div&gt; &lt;div class="read-more"&gt;&lt;a href="&lt;?php echo get_permalink(); ?&gt;"&gt;Read more&lt;/a&gt;&lt;/div&gt; &lt;?php endwhile; ?&gt; &lt;br/&gt;&lt;br/&gt; &lt;div class="wp-paginate"&gt; &lt;?php wp_reset_query(); echo paginate_links( array( 'base' =&gt; $baselink.'%_%', 'total' =&gt; ceil($total/$post_per_page), 'current' =&gt; $paged, )); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- end content --&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre> <p>This could all be in one file, or you can use it in two pieces as I have written it.</p> <p>EDIT:</p> <p>Sorry I have it set to also grab the images from the post. I think this is the functions code you need:</p> <pre><code>function get_images_by_cat($id){ $limit = 1000; $the_query = new WP_Query("posts_per_page={$limit}&amp;cat={$id}"); $arr = array(); while ( $the_query-&gt;have_posts() ) { $the_query-&gt;the_post(); $title = get_the_title(); $image_src = get_field('banner_image'); $image_link = get_field('banner_link'); $arr[] = array( "title" =&gt; $title, "link" =&gt; $image_link, "image" =&gt; $image_src, ); } wp_reset_query(); return $arr; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload