• Resolved ssccdd

    (@ssccdd)


    I apologize if this is covered somewhere but I couldn’t seem to find anything I could understand, I have total entry level php skills.

    I’m making a portfolio site and the pieces are entered as posts, so I wanted a constant footer on each page that displays every post as a thumbnail + title in a grid (not a slider). Is there a widget for this I could use, or some php function I could add to the footer?

    Think this was close but wasn’t sure how to implement it: https://stackoverflow.com/questions/6184385/how-to-show-all-of-my-posts-with-thumbnail-with-title-on-a-single-page-in-wordpr :

    <?php $args = array( 'numberposts' => -1 );
        // optionally put more arguments here
        // see wordpress function reference, 'get_posts'
        // -1 for number of posts displays all
        $postlist = get_posts($args);
        foreach ($postlist as $post) {
            setup_postdata($post);
            if (has_post_thumbnail()) {
                echo '<h2><a href="';
                the_permalink();
                echo '">';
                the_title();
                echo '</a></h2>';
                the_post_thumbnail();
                // alter markup and style accordingly
                // optionally add thumbnail class as function parameter
                // as previously defined in functions.php
            }
        }
    ?>

    I’m using the roots.io bootstrap framework.

    any help would be GREATLY appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ssccdd

    (@ssccdd)

    immediately after posting it i realized i wasn’t setting a featured image, the code is working now, sorry! but if anyone still has advice on how to get each thumbnail in a 6 column grid that would be great.

    If you want the 6 contentblocks (thumbnail and title) to be horizontally aligned, set the css display property of the contentblocks to inline or inline-block.

    More info here: https://www.w3schools.com/cssref/pr_class_display.asp

    Or you could use a table to give the blocks equal width:
    https://cssdesk.com/Nkt7a

    Or you could use a fluid layout system, which is a bit more complex.

    Thread Starter ssccdd

    (@ssccdd)

    hm the inline block thing didn’t totally work because i don’t have a finite number of divs in a row to enclose in a table row. here’s what happens https://i.imgur.com/yguBb8v.jpg (the green is the inline block and the red is a block wrapper)
    anyway probably just need to mess with the css not too worried about that.

    my main remaining issue is that code doesn’t pull in thumbnails for me, rather the full image. wanted to make the images all square thumbnails, and from reading the codex that should pull in the thumbs, i have “add_theme_support( ‘post-thumbnails’ );” in the functions.php. any ideas on why this is happening?

    still using mostly the same code posted above

    thanks for your help tokant!

    Thread Starter ssccdd

    (@ssccdd)

    hahaha immediately after posting this i noticed my mistake.

    had:
    the_post_thumbnail();

    when it should have been:
    the_post_thumbnail(‘thumbnail’);

    now it works and everything looks lined up!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying all posts as thumbnails’ is closed to new replies.