Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter subfusioncom

    (@subfusioncom)

    I’m getting there….

    The code below will write a sub page class as the parent page ID number but I’d like it to write the class as the parent page name (numbers dont work in css).

    if (is_page('naturopathy')) {
                 echo 'home';
            } elseif (is_page('about')) {
                 echo 'about';
    		} elseif (is_page('services')) {
                 echo 'services';
    		} elseif (is_page('products')) {
                 echo 'products';
    		} elseif (is_page('contact')) {
                 echo 'contact';
    		} elseif ($post->post_parent) {
    			 echo $post->post_parent;
    		}
    Thread Starter subfusioncom

    (@subfusioncom)

    if (is_page('widgets')) {
                 echo 'home';
            } elseif (is_page('about')) {
                 echo 'about';
    		} elseif (is_page('services')) {
                 echo 'services';
    		} elseif (is_page('products')) {
                 echo 'products';
    		} elseif (is_page('contact')) {
                 echo 'contact';
    		} elseif ($post->post_parent) {
    			 the_title('','',false) echo '[post_parent]';
    		}

    I can create the right class for a specific page as in the code above but in the last line I’m trying to print the parent page name so that the sub page inherits the parent page class. I realise [post parent] isn’t going to work! I’m still new but once I’ve grasped this then I think I can be more self sufficient.

    Thanks for your help so far adambrown any more suggestions would be appreciated….

    Am I nearly there yet?

    Thread Starter subfusioncom

    (@subfusioncom)

    Thanks for that. I can now make the class the same as the page name but how do I make the class the name of the parent page for a sub-page?

    Thread Starter subfusioncom

    (@subfusioncom)

    Thanks, much appreciated

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