WordPress.org

Ready to get started?Download WordPress

Forums

Grid of Pages - How to hide current Page from being displayed in the grid (3 posts)

  1. mikono
    Member
    Posted 2 years ago #

    Hi, i have a grid based Page Preview under my content on my 'home' page. the problem is, that in the grid view the 'home' page is listed again. how can i hide the current page from being displayed?

    i load the Parent Pages by using :

    <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts( 'post_type=page&post_parent=0&orderby=menu_order' );
        get_template_part( 'leistungen', 'grid' );
        wp_reset_query();
    ?>

    i use this in a similar way on an other page as well, just that i only call the child pages of that page. all child pages will have the preview in a grid of the other child pages with the same parent. i am looking for a solution i could use in generell, if thats possible.. Thanks in advanced for help!

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    try:

    <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts( array(
    'post_type' => 'page',
    'post_parent' => 0,
    'orderby' => 'menu_order',
    'post__not_in' => array($post->ID)
    ));
        get_template_part( 'leistungen', 'grid' );
        wp_reset_query();
    ?>

    (untested)

    http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
    http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

  3. mikono
    Member
    Posted 2 years ago #

    Thank you so much!!! I was close already, but this is a very smooth and charmingly easy solution!!!! Happy New Year alchymyth, you already made mine! :)

Topic Closed

This topic has been closed to new replies.

About this Topic