使用PHP将Div分为两个Div,这是一个Wordpress函数

I'm trying to wrap a div around two other div's. Inside those divs are wordpress functions.

For example:

  1. Home Display Div
  2. Home Display Left Div
  3. Wordpress function
  4. (close jhome left div)
  5. Home Display Right Div
  6. wordpress function
  7. (close home right div)
  8. Close Home Display Div

I already have the functions working correctly, but I'm trying to use the following code in my page template:

echo '<div class="home-display">';

function home_display_left() {
echo '<div class="wrap">';
genesis_widget_area( 'home-display-left', array(
'before' => '<div class="home-display-left">',
'after' => '</div></div>',
) );
}
function home_display_right() {
echo '<div class="wrap">';
genesis_widget_area( 'home-display-right', array(
'before' => '<div class="home-display-right">',
'after' => '</div></div>',
) );
echo '</div></div>';
}
echo '</div> ';

What's the correct code that I should be putting in my page template?

What you've got there is the home-display div class wrapped around two function definitions. That is, the functions are not run iteratively between the two echo statements - they are simply defined there. You would have to wrap your div tags around where the functions are called, or create a new function to include them:

function home_display_left_right() {
    echo '<div class="home-display">';
    home_display_left();
    home_display_right();
    echo '</div> ';
}

Alternatively, include the open and close div tags as needed in the existing definitions:

function home_display_left() {
    echo '<div class="home-display">'; // open .home-display
    echo '<div class="wrap">';
    genesis_widget_area( 'home-display-left', array(
    'before' => '<div class="home-display-left">',
    'after' => '</div></div>',
    ) );
}
function home_display_right() {
    echo '<div class="wrap">';
    genesis_widget_area( 'home-display-right', array(
    'before' => '<div class="home-display-right">',
    'after' => '</div></div>',
    ) );
    echo '</div></div>';
    echo '</div> ';  // close .home-display
}