WordPress.org

Forums

Virtue
Defining body class for custom php (7 posts)

  1. royamathew
    Member
    Posted 1 year ago #

    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

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

  3. royamathew
    Member
    Posted 1 year ago #

    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

  4. Kadence Themes
    Member
    Theme Author

    Posted 1 year ago #

    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;
    } ?>
  5. royamathew
    Member
    Posted 1 year ago #

    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

  6. royamathew
    Member
    Posted 1 year ago #

    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

  7. Kadence Themes
    Member
    Theme Author

    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.