• Resolved sweetberry

    (@sweetberry)


    Hi,
    i want to use a different css fo all subpages of the page games for example

    <?php if ( is_page(wp_list_pages('title_li=&child_of='.$post->ID) )  ) { ?> 
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/hidepostcontainer.css" type="text/css" media="screen" />
    <?php } else { ?>
    
    	<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
    <?php } ?>

    i think i got to replace the ” _of=’.$post->ID ” in the list_page function but i don’t get it to work, i also tried:

    <?php if ( is_page(wp_list_pages('title_li=&child_of='.$post->ID) and is_category('games') )  ) { ?>

    if i write the id’s by hand in the is_page(”) function everything works fine, if i don’t replace the &child_of=’.$post->ID it just does it for every page like it should

    thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Could try:

    <?php
    global $post;
    
    if ( is_single() && 100 == $post->post_parent ) { ?>
        <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/hidepostcontainer.css" type="text/css" media="screen" />
    <?php } else { ?>
        <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" />
    <?php } ?>

    Make sure to change the “100” to the ID of your “Games” page.

    Thread Starter sweetberry

    (@sweetberry)

    thank you , but it didn’t work i replaced the “100” with “games” and “10” it seems to have no effect
    i also tried placing a is_page() function before the && because i didn’t exactly understand your syntax

    i just need the correct statement for the is_page function like is_page(subpage of music)
    everything else semmes to work properly
    i’m also not sure if i got to declare it as an array?

    ‘is_page(array(‘puzzle’,’action’,’games’,’other’))’

    Thread Starter sweetberry

    (@sweetberry)

    My attempt was supposed to check that the current page is a single page (as you don’t want this to ever return true anywhere else) and that the current page’s parent has an id equal to that of your games page’s id. You can’t use wp_list_pages() the way you are trying; that function doesn’t return an array/string of pages, it simply displays a list of links:

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

    Yes, is_page() can take an array of page ID’s, names, or slugs.

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

    It might be easier to add a new category (Game Page for example) to each of those pages and then check for it instead:

    if ( is_single() && in_category( 'Game Page' ) ) {

    Thread Starter sweetberry

    (@sweetberry)

    thank you very kind sir!
    thank you very much 🙂
    finally i ended up with this solution after adding categorys to my pages it works very fine 🙂

    <?php if ( in_category( ‘Games’ ) ) { ?>

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding condition 'all subpages of '’ is closed to new replies.