• Seiden

    (@seidenkaczka)


    Hello,

    I would like to display a list of pages (not posts…) with thumbnails.
    But I want to display only the pages from a specific category. As I didn’t find anything to select pages from a category, I used metadata instead.
    I tried several things, several tips from several support boards, and I finally got a working code…. Well, at least, it worked when I was testing it on my homepage. But now that I copy/pasted it into my custom template, it doesn’t show anything…
    If I copy my entire homepage and paste it into my custom template, I get my exact homepage, but still without the page list….

    So, here is my current custom template:

    <?php
    /*
    Template Name: Catégorie
    */
    
    get_header();
    
    global $more;
    $more = 0;
    ?>
    
    	<div id="content-blog" class="<?php echo esc_attr( implode( ' ', responsive_get_content_classes() ) ); ?>">
    
    	<?php
        $product_pages_args = array(
            'meta_key' => 'Categorie',
            'meta_value' => 'lycéens',
            'depth' => -1,
            'hierarchical' => 0
        );
    
        $product_pages = get_pages( $product_pages_args );
    	?>
    	<ul>
        <?php
        foreach ( $product_pages as $product_page ) {
    	echo '<a href="<?php echo get_page_link( $page->ID ); ?>">';
    	echo get_the_post_thumbnail( $page->ID, 'medium' );
    	echo '</a>';
        echo '<li><a href="' . get_permalink( $product_page->ID ) . '">' . $product_page->post_title  . '</a></li>';
        }
        ?>
    </ul>
    	Do you see me? 
    
    <?php get_footer(); ?>

    I get my header and my footer, and the “Do you see me?” that is there to be sure there is a content. But my list of pages won’t show. I feel kinda lost because that exact same code works really well on my homepage.

    Is there any way to get a list of my pages sorted by category (or metakeys) with pictures? Or can someone explain me how to make this code work? I’m really new to wordpress, started using it a few weeks ago and I don’t know much about php… Also, I’m sorry for my English mistakes, this is not my usual language.

    I can’t show you the website because it’s still on localhost.

    I still hope someone can help me.

    Thank you.

Viewing 1 replies (of 1 total)
  • trishahdee

    (@trishahdee)

    I’m trying to do something similar. I want to get the thumbnails and titles of specific pages to list on a front page. Page-list plugin does what I want but it doesn’t allow me to specify the order of the pages displayed.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting a list of specific pages with thumbnails’ is closed to new replies.