13 lip 2012

Formatowanie telefonu

!{$mobile|regex_replace:"/^([0-9]{3})([0-9]{3})([0-9]{3})/":"$1 $2 $3"}!
!{$phone|regex_replace:"/^([0-9]{2})([0-9]{3})([0-9]{2})([0-9]{2})/":"$1 $2 $3 $4"}!
27 mar 2012

Odczyt kategorii posta

$arr_cat=get_the_category($post->ID);

Przykładowe zastosowanie:

if(is_single()):
Kategorie
$cat=''; $arr_cat=get_the_category($post->;ID);
for($i=0,$c=count($arr_cat);$i<$c;$i++) { if($c>1 && $arr_cat[$i]->cat_ID==8) continue; $cat.=','.$arr_cat[$i]->cat_ID;
  };
  $cat=substr($cat, 1);

  $recent = new WP_Query("cat=".$cat."&showposts=10");
  while($recent->have_posts()) : $recent->the_post();
  ...
  endwhile;
  endif;