WordPress.org

Support

Support » Themes and Templates » Defining body class for custom php

Defining body class for custom php

  • royamathew
    Member

    @royamathew

    Would anybody know how to define a custom php page body class. I want to define the page’s body class as full width in virtue them.
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael
    Forum Moderator

    @alchymyth

    royamathew
    Member

    @royamathew

    yes i saved the fullwidth page template pagefullwidth.php as another page template (Another.php). But i am not sure how to specify the style as a fullwidth page

    Theme Author Kadence Themes
    Participant

    @britner

    Hey, It’s done using a function. Here is an example, you can stick this in your child theme.

    <?php add_filter('kadence_display_sidebar', 'kad_sidebar_on_special_page');
    function kad_sidebar_on_special_page($sidebar) {
      if (is_page_template('another.php')) {
        return false;
      }
      return $sidebar;
    } ?>
    royamathew
    Member

    @royamathew

    Hi,
    Thanks. I did try the code but it does not make any change. Is there any additional code i should be adding. Reply is much appreciated

    royamathew
    Member

    @royamathew

    my template page another.php has the following code

    <?php /* Template Name: Another
    */
    ?>

    <?php add_filter(‘kadence_display_sidebar’, ‘kad_sidebar_on_special_page’);
    function kad_sidebar_on_special_page($sidebar) {
    if (is_page_template(‘Another.php’)) {
    return false;
    }
    return $sidebar;
    } ?>

    <div id=”pageheader” class=”titleclass”>
    <div class=”container”>

    <?php get_template_part(‘templates/page’, ‘header’); ?>
    </div><!–container–>
    </div><!–titleclass–>

    <div id=”content” class=”container”>
    <div class=”row”>
    <div class=”main <?php echo kadence_main_class(); ?>” role=”main”>
    <?php get_template_part(‘templates/content’, ‘page’); ?>
    </div><!– /.main –>

    any thoughts

    Theme Author Kadence Themes
    Participant

    @britner

    That won’t work. Sorry not explaining well. The function I sent doesn’t go in the template file I goes in your child theme functions.php file.

    Kadence Themes

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Defining body class for custom php’ is closed to new replies.