Riprendendo l’ottimo post di Francesco Gavello WordPress Little Trick – functions.php e commenti nidificati sull’utilità del file functions.php presente nei temi WordPress, ecco altre funzioni utili da utilizzare per tutti i vostri temi:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | /** * Recupera gli ultimi n post * * @param $n (number) Numero di post da estrarre * @param $c (number) ID della categoria: lasciare vuoto per "tutte" * @param $b (string) TAG (prima) usato per racchiudere i link (defautl <li>) * @param $a (string) TAG (dopo) usato per racchiudere i link (defautl </li>) * * @result (string) Elenco degli ultimi post * */ function ul_get_recent_posts( $n = 5, $c = '', $b = "<li>", $a = "</li>" ) { $o = ''; $l = new WP_Query( "showposts=" . $n.( ($c!='')?'&cat='.$c:'' ) ); while($l->have_posts()) { $l->the_post(); $o .= $b.'<a rel="bookmark" title="Permanent Link: '.get_the_title().'" href="'.get_permalink().'">'.get_the_title().'</a>'.$a; } return $o; } /** * Recupera il valore di custom field (campo personalizzato) * * @param $k (String) Chiave/ID del custom field * * @return Valore del Custom Field */ function ul_get_custom_field( $k ) { global $post; return( get_post_meta( $post->ID, $k, true ) ); } |








7
Non ci sono commenti per questo Post
Lascia un commento