php - Two different get_posts() returning same post -


i using wordpress , trying create boxes retrieving information adanvec customs fields on custom post type.

i have code:

<div class="col-sm-2 hidden-xs">     <?php     $box1 = get_front_page_box("box 1");     $style_front = get_box_style($box1->id, "front");     echo $box1->id;     ?>     <div id="front-box-1" class="front-box height-low <?php echo $box1->id; if(has_back_panel($box1->id)) echo "flip"; ?>">         <div class="front" style="<?php echo $style_front; ?>"><a href="#">banana</a></div>         <?php         if(has_back_panel($box1->id)):             $style_back = get_box_style($box1->id, "back");         ?>         <div class="back" style="<?php echo $style_back; ?>"></div>         <?php endif; ?>     </div> </div> <div class="col-sm-5 hidden-xs">     <?php     $box2 = get_front_page_box("box 2");     $style_front = get_box_style($box2->id, "front");     echo $box2->id;     ?>     <div id="front-box-2" class="front-box height-low <?php echo $box2->id; if(has_back_panel($box2->id)) echo "flip"; ?>">         <div class="front" style="<?php echo $style_front; ?>"><a href="#">banana</a></div>         <?php         if(has_back_panel($box2->id)):             $style_back = get_box_style($box2->id, "back");         ?>         <div class="back" style="<?php echo $style_back; ?>"></div>         <?php endif; ?>     </div> </div> 

and these functions:

function get_front_page_box($name) {     $args = array(         'post_title'   => $name,         'post_type'    => 'front-page-box',         'post_status'  => 'publish'     );      $box_array = get_posts($args);      $box = $box_array ? $box_array[0] : false;      print_array($box);     return $box; }  function get_box_style($id, $side) {     $style = "";     if(get_field($side."_panel_background_color", $id)) $style = "background-color:".get_field($side."_panel_background_color", $id).";";      return $style; }    

but reason both boxes have same details (both box 2). idea why these returning same info? both posts ("box 1" , "box 2" exist under front-page-boxcustom post type.

seems post_title not valid filter. found out there's specific function posts title.

get_page_by_title

used $box1 = get_page_by_title("box 1", null, "front-page-box");


Comments