php - code is skipping a div

admin2025-04-18  1

In header.php I have created a div to contain my navigation menu area. Within the div is 1 x do_shortcode and 2 x includes php files. For some reason the last include ('custom-primary-menu.php') is skipping <header id="masthead" and <div id="page" class="hfeed site"> and is only within <div class="col-full">. The other 2 however, appear as they should.

I thought it might have something to do with the open div at the end of the code which is also "col-full" but I tried renaming the first and it made no difference.

<?php
?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2.0">
<link rel="profile" href="">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<?php do_action( 'storefront_before_site' ); ?>

<div class="col-full">
    <div id="page" class="hfeed site">

        <?php do_action( 'storefront_before_header' ); ?>

        <header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">


            <?php   

            do_action( 'storefront_header' );
            ?>

            <?php
            echo do_shortcode ('[woo_multi_currency_layout5]');
            include ('secondary-icon-menu.php');
            include ('custom-primary-menu.php');
            ?>

        </header><!-- #masthead -->
    </div>
</div>

    <?php

    do_action( 'storefront_before_content' );
    ?>

    <div id="content" class="site-content" tabindex="-1">
        <div class="col-full">

        <?php
        do_action( 'storefront_content_top' );
            ?>

In header.php I have created a div to contain my navigation menu area. Within the div is 1 x do_shortcode and 2 x includes php files. For some reason the last include ('custom-primary-menu.php') is skipping <header id="masthead" and <div id="page" class="hfeed site"> and is only within <div class="col-full">. The other 2 however, appear as they should.

I thought it might have something to do with the open div at the end of the code which is also "col-full" but I tried renaming the first and it made no difference.

<?php
?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2.0">
<link rel="profile" href="http://gmpg/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<?php do_action( 'storefront_before_site' ); ?>

<div class="col-full">
    <div id="page" class="hfeed site">

        <?php do_action( 'storefront_before_header' ); ?>

        <header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">


            <?php   

            do_action( 'storefront_header' );
            ?>

            <?php
            echo do_shortcode ('[woo_multi_currency_layout5]');
            include ('secondary-icon-menu.php');
            include ('custom-primary-menu.php');
            ?>

        </header><!-- #masthead -->
    </div>
</div>

    <?php

    do_action( 'storefront_before_content' );
    ?>

    <div id="content" class="site-content" tabindex="-1">
        <div class="col-full">

        <?php
        do_action( 'storefront_content_top' );
            ?>
Share Improve this question asked Dec 3, 2019 at 13:39 aye ceeaye cee 15912 bronze badges 4
  • 1 I'm not sure about the answer to your include/div question, but please... don't echo do_shortcode(). Just find the callback and use it directly. – butlerblog Commented Dec 3, 2019 at 14:08
  • I have searched this plugins files for add_shortcode to find the function and came up with nothing. If I did find it, would I just echo the function name instead? – aye cee Commented Dec 3, 2019 at 14:31
  • You could start by just echoing the function name. It'll depend on the actual function and whether it's in a class or not. – butlerblog Commented Dec 3, 2019 at 15:18
  • 1 Code ordering problems sometimes have to do with echoing instead of returning. You might try either echoing all, or returning all, to see if making them all the same puts them all in the same place. – WebElaine Commented Dec 3, 2019 at 15:44
Add a comment  | 

1 Answer 1

Reset to default 0

ok after days of doing the same thing over and over...menting out different combinations of files...I realised the problem was actually an extra closing div which the code editor threw in for me in one of the files!!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744931835a275204.html

最新回复(0)