Skip to main content
edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
changes done
Source Link
Naren Verma
  • 249
  • 1
  • 6
  • 19

My output isMy output is

//I am getting my output here
    <div class="cp-seeWrapper">
      <div class="container">
        <div class="row">
          <div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12">
          </div>
          <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <div class="cp-social"></div>
            <div class="cp-newsletter"></div>
          </div>
        </div>
      </div>
    </div>

I have created widget on function.php

function cp_newsletters() {
    register_sidebar( array(
        'name'          => 'Newsletter',
        'id'            => 'cp_newsletter',
        'before_widget' => '<div class="chw-newsletter">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2 class="chw-newsletter_title">',
        'after_title'   => '</h2>',
    ) );

}
add_action( 'widgets_init', 'cp_newsletters' );

My output is

//I am getting my output here
    <div class="cp-seeWrapper">
      <div class="container">
        <div class="row">
          <div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12">
          </div>
          <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <div class="cp-social"></div>
            <div class="cp-newsletter"></div>
          </div>
        </div>
      </div>
    </div>

My output is

//I am getting my output here
    <div class="cp-seeWrapper">
      <div class="container">
        <div class="row">
          <div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12">
          </div>
          <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <div class="cp-social"></div>
            <div class="cp-newsletter"></div>
          </div>
        </div>
      </div>
    </div>

I have created widget on function.php

function cp_newsletters() {
    register_sidebar( array(
        'name'          => 'Newsletter',
        'id'            => 'cp_newsletter',
        'before_widget' => '<div class="chw-newsletter">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2 class="chw-newsletter_title">',
        'after_title'   => '</h2>',
    ) );

}
add_action( 'widgets_init', 'cp_newsletters' );
Source Link
Naren Verma
  • 249
  • 1
  • 6
  • 19

Dynamic HTML not displaying at respective place

Dynamic HTML not displaying at respective place I have a created shortcode in function.php and my code is,

function Post_home(){
$data='<div class="cp-seeWrapper"><div class="container"><div class="row"><div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12">';

  //some logic here
      
  $data.='</div>';
  $data.='<div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12"><div class="cp-social">';
            if (is_active_sidebar('footer-social')) :
                 dynamic_sidebar('footer-social');
                endif;
  $data.='</div><div class="cp-newsletter">';
           if (is_active_sidebar('cp_newsletter')) :
                 dynamic_sidebar('cp_newsletter');
                endif;
  $data.='</div></div></div></div></div>';
 return $data;    
}
add_shortcode( 'home_post', 'Post_home' );

Now just notice here, Whatever I am adding the logic part that output is displaying before the parent div. I mean my parent div is cp-seeWrapper and output is displaying before it.

I added footer-social and newsletter logic and both are displaying above parent div.

Would you help me out?

My output is

//I am getting my output here
    <div class="cp-seeWrapper">
      <div class="container">
        <div class="row">
          <div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12">
          </div>
          <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <div class="cp-social"></div>
            <div class="cp-newsletter"></div>
          </div>
        </div>
      </div>
    </div>