• Hello, i’ve been trying to wokr this out but seems like i just couldn’t.

    i have got a sub menu
    <ul id="second"> <?php wp_list_pages('child_of=6&sort_column=post_title&title_li=&sort_column=menu_order') ?>

    wich should only be show if you are on a certain page or it’s subpages.

    im’ guessing i should go with the is_page function and ad them all, but it’s somehow not working for me, i don’t know if it is just becuase is in the header just before the loop.

    thanks in advance for your help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • I think you are right about the list page thing. You can use List subpage plugin instead.

    is_page() should work before, after or within the Loop. The slightly trickier part would be creating a conditional for the sub-pages – which would need a check made on the current page’s parent to determine if you’re on one of the relevant child pages.

    Thread Starter furiber

    (@furiber)

    @ esmi yes, you’re right, but since i haven’t got that many pages i can just check the ones that don’t have it (that are actually 3).

    Anyways i have done it through css.

    Thank you both.

    @esmi, I don’t think that is_page() will work after or in the loop itself.

    http://codex.wordpress.org/Function_Reference/is_page

    I’m currently trying to use conditional statements in my sidebar.php to load different sidebars depending on the page calling them (and failing to do so). I’m using is_page(‘blog’) as an example and it returns false after the loop or in it. However, before (just as the codex page says) it works fine. I’ve also attempted to call wp_query_reset() after the loop as the codex suggests and it still returns false.

    I know this is a different topic, but if anybody has suggestions for me, I’d greatly appreciate them.

    Thanks

    try wp_reset_query()

    http://codex.wordpress.org/Function_Reference/wp_reset_query

    (unless in your thread, wp_query_reset() was just a typo, then ignore this reply)

    @alchymyth – thank you for your response. I can’t remember if what I typed is what I had or not (it was late and I had been on a long stretch of coding…) Anyway, I did try wp_reset_query() and it still doesn’t work.

    Here are some things that maybe can help:

    1. I’m placing the call to wp_reset_query() directly after the endwhile; line that ends the loop.
    2. In the sidebar, I’m using if( is_page ( 'articles' ) as the conditional line (the post_name value in the database is ‘articles’, but I’ve also tried the post_title value as well and that doesn’t work either).

    I might try the $temp_query = $wp_query method next and see if that works, but wouldn’t wp_reset_query() do the same thing?

    Thanks again for all of your help.

    Just to clarify too, I’ve used is_page ( 'blog' ) and is_page ( 'articles' ) as well as is_page ( 'Brand Blog' ) and none of them have any affect :-\

    you could try to use ‘wp_reset_query()’ directly before the if( is_page( '...' ) )

    are you using a free available theme?
    if so, could you post the name and download link?

    are the pages you are trying all static pages, or pages with page templates?

    if you are aiming for the ‘posts’ page, as set in the admin aettings under ‘reading’ then you might need to use a different conditional tag such as is_home()

    Well, I’m using my own theme and I originally had issues setting the home page to static (it was replicating the home page template on the blog page). I resolved those though as far as I can tell, but it seemed odd to me that it was doing that. What I believed fixed it was changing the “home” template to “main.php” instead of “home.php”.

    Here’s the link to my test site that I’m using on this example: http://praeix.com/

    As you can see the home page is drastically different than the rest of the layout. Each subpage has it’s own page template.

    What I’m aiming for is to be able to have different sidebars on each subpage, but use on single file ‘sidebar.php’ for all of them.

    BTW, I tried to use ‘wp_reset_query()’ directly before the conditional in ‘sidebar.php’ and it didn’t work either 🙁

    As an info for anybody reading this…I’m taking the test site off of the previous link that I posted (http://praeix.com/). The real site (without dynamic sidebar…until I get it working) is at http://fronterahouse.com/

    In the meantime, I’m going to create a new thread in regards to this sidebar issue.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘listing sub pages after is_page outside the loop’ is closed to new replies.