php - Wordpress image caption doesn't display correctly -


i have wordpress page, in images appears on left , text appears on right. images fall down under text when page loaded on mobile screen. have php code achieve of that, switchs image , text places, , attributes left or right each.

but since in place, have trouble adding images' captions. when want add images' captions in wordpress admin, caption doesn't come under image comes text article (so, on right part of page). guess php code attributes automaticaly place every text.

i need images' captions under images, , guess has lot php code can see below. don't know how fix that.

here php:

<?php if (have_posts()):  ?>    <div class="container">      <?php while(have_posts()): the_post(); ?>        <div class="row">          <div id="content_post">            <div class="col-lg-push-5 col-lg-6 col-md-push-6 col-md-6 col-sm-12 col-xs-12 ">						              <?php                 //get content office , filter imgs except featured img place them later in  <div id='img_content_right'>                $content2 = get_the_content();                                    $removed_imgs = array();                                 $content2 = preg_replace_callback('#(?!<img.+?id="featured_img".*?\/>)(<img.+? />)#',function($r) {                global $removed_imgs;                $removed_imgs[] = $r[1];                return '';                },$content2);                  //add filter the_content strip images except img_menu et featured_img                          add_filter('the_content', 'strip_images',2);                                    function strip_images($content){                            $content=preg_replace('/(?!<img.+?id="img_menu".*?\/>)(?!<img.+?id="featured_img".*?\/>)<img.+?\/>/','',$content);                                                  return $content;                                            }                the_content();               ?>            </div>          </div>	          <div class="col-lg-pull-6 col-lg-5 col-md-pull-6 col-md-6">	            <div id='img_content_right'>              <?php                     //append images stripped content              foreach($removed_imgs $img){              echo $img; }  ?>            </div>	          </div>             </div>      </div> 	    <?php endwhile; ?>  <?php endif; ?>	

to appropriately handle caption need attachment post object , @ post_excerpt.

there's function in wordpress get_attached_media, list of images within posts content. easier iterate on using regex find images.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -