wordpress - Create php function to use inside while loop -



wordpress - Create php function to use inside while loop -

how can create function utilize within while loop. the_title() or the_meta() in wordpress? simple sample enough.

you utilize globals. example, assuming have global array, here (obviously need add together more robustness such error checking. plus how utilize on wordpress depend on doing)

$post= array( 0=>array('title'=>'the title', 'content'=>'this content'), 1=>array('title'=>'the sec title','content'=>'we love seconds'), ); $array_index=0; the_title(); the_post(); next_post(); the_title(); the_post(); function the_title() { global $post, $array_index; echo $posts[$array_index]['title']; } function the_post() { global $post, $array_index; echo $posts[$array_index]['title']; } function next_post() { global $post, $array_index; $array_index++; }

php wordpress function

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -