Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Darfuria

    (@darfuria)

    Resolved thanks to KMxRetro of RewiredMind

    <?php if (is_page()) { ?>
    <?php $cssdir = get_permalink(); ?>
    <?php $holder = explode("/",$cssdir) ?>
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/page.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/<?php echo $holder[3]; ?>/style.css" type="text/css" media="screen" />
    <?php } ?>

    May work differently on a different URL structure, but works on my template – so far so good.

    This is an alternative I found and constructed from all the help on the forums here so thought this was the best place to post as it was so very close but no cigar for me:

    <?php
    $parent = get_page($post->post_parent);
    $grandparent = $parent->post_parent;
    ?>
    
    <?php
    
    if ( is_page('corporate-training') || $post->post_parent == '59' || $grandparent == '59' ) {
        $stylesetting = 'training.css';
    
    } elseif ( is_page('hotbedfest') || $post->post_parent == '55' || $grandparent == '55' ) {
        $stylesetting = 'hotbed.css';
    
    } elseif ( is_page('productions') || $post->post_parent == '10' || $grandparent == '10' ) {
        $stylesetting = 'productions.css';
    
    } else {
        $stylesetting = 'style.css'; // Fall-through
    }	
    
    ?>
    
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/<?php echo $stylesetting; ?>" type="text/css" media="screen" />

    Thanks to all you great people..

    I am having a similar problem. I used a conditional to change the banner, background, etc. on a couple of pages. However, the subpages to those pages revert back to the default style. In my header.php I posted the following code:

    <?php if (is_page('creation')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style_creation.css" type="text/css">
    <?php }; ?>
    <?php if (is_page('anarchism')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style_anarchism.css" type="text/css">
    <?php }; ?>

    This works fine for those particular pages. But like I said, the subpages revert to default. I am not quite sure how to get the subpages to follow suit.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subpage get parent page slug’ is closed to new replies.