Would appreciate help. I'm trying to figure out how to build a menu page where there are pictures or photos with a summary with a link to a post or article. Like a grid or a similar shape. (Not using categories) It's clear to me that this is probably a basic thing that I have not been able to crack gently :( Thanks in advance.

  • Hi -- I think you'll need to provide more information. Where are you trying to build such a page? For the front-end of your site? Are you creating a custom theme or plugin, or are you using one and want to extend its layout capabilities?
    – tmdesigned
    Mar 28 '19 at 10:27
  • Hi i am trying to build a discography page which will be linked to the menu. In the page i want to have a grid of cd pictures with a link to information of the cd etc...
    – LoveIsHere
    Mar 28 '19 at 11:01

Use WP_Query for getting the posts you want. Then you can loop through them and get their title, their featured image and their excerpt to be printed they way you want. Something like that:

<?php $args = [
    'post_type'      => 'post',
    'post_status'    => 'publish',
    'posts_per_page' => 9,
    'order'          => 'DESC',
    'orderby'        => 'date',
]; ?>

<?php $the_query = new WP_Query( $args ); ?>

<?php if ( $the_query->have_posts() ) : ?>
    <div class="my-grid">

    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <div class="grid-item">

           <div class="thumbnail"><?php the_post_thumbnail(); ?></div>
           <div class="title"><?php the_title(); ?></div>
           <div class="excerpt"><?php the_excerpt(); ?></div>

    <?php endwhile; ?>

    <?php wp_reset_postdata(); ?>

<?php else : ?>
    <p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

And the rest is just CSS.

  • hi, thanks how where di I access the wp query I mean where do I paste this? secondly are you familiar with a simpler plugin I am not that good in understanding PHP and how to work with it?
    – LoveIsHere
    Mar 28 '19 at 9:12
  • 1
    At best you place this snippet as-is in your theme's header.php. Asking for plugins is off-topic. But I came up with wordpress.org/plugins/grid-plus in 5 seconds of searching. And more can be found here: wordpress.org/plugins/tags/grid-layout
    – leymannx
    Mar 28 '19 at 9:16
  • brilliant. sorry, did not know its off topic but it helped me a lot. !!!
    – LoveIsHere
    Mar 28 '19 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.