change slug for multiple pages with same root

  • dianaascher

    #38857

    Thank you! You really saved my bacon. So grateful!!!

    dianaascher

    #38858

    So now that the function identifies the pages that should have the same header, can I use that same format to change things like sidebar colors, etc.? Is there a standard format I can apply?

    Anonymous

    #38859
    Quote:
    ..can I use that same format to change things like sidebar colors, etc.?

    Since each page has an unique ID, you can change sidebar colours etc, with just Custom CSS.

    dianaascher

    #38860

    Yes, each page has a unique ID, but the site will evolve with new pages and posts and I doubt my client could go in and ad new IDs to the CSS. I was thinking that now that there is a mechanism to identify the pages that require the secondary style, there could be some way to change items in addition to the header.

    Admin

    Syahir Hakim

    #38861

    You can add this to the child theme’s functions.php file:

    /**
    * Add custom body class
    */
    function my_body_class( $classes ) {
    $parent_id = 65; /* Change to the ID of the parent page */
    $current_post = get_post( $post_id );
    if ( in_array( $parent_id, array( $current_post->ID, $current_post->post_parent ) ) ) $classes[] = 'a-main';

    return $classes;
    }
    add_action( 'body_class', 'my_body_class' );

    That will add the .a-main class to the <body> element, so you can use that to prefix the CSS codes to be applied to those pages.

    dianaascher

    #38862

    Ingenious. Thank you so much. You guys are the most responsive developers I’ve come across and when I finally finish this thing and get paid, I will definitely be making a donation to the Graphene cause. Great work and great support. Thank you.

Viewing 6 posts - 11 through 16 (of 16 total)

  • 1
  • 2
  • You must be logged in to reply to this topic.