Wordpress: functions.php, certains utiles

Reprenant les messages excellente par Francis Gaven WordPress petit truc - functions.php et commentaires imbriqués sur l'utilité du fichier functions.php présents dans WordPress thèmes, voici d'autres fonctions utiles à utiliser pour tous vos thèmes:

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
/ **
* Récupérer les derniers messages n
*
* Nombre @ param $ n (nombre) des messages à extraire
* @ Param $ c (nombre) ID de catégorie: Laissez vide pour "tous"
* @ Param $ b (string) TAG (première) utilisés pour encadrer le lien (defautl <li>)
* @ Param $ un TAG (chaîne) (après) utilisé pour enfermer le lien (defautl </ li>)
*
* Résultat @ (string) Liste des dernier message
*
* /
$n = 5 , $c = '' , $b = "<li>" , $a = "</li>" ) { Fonction ul_get_recent_posts (n = 5 $, $ c ='', $ b = "<li>", $ a = "</ li>") {
'' ; O $ ='';
new WP_Query ( "showposts=" . $n . ( ( $c != '' ) ? '&cat=' . $c : '' ) ) ; $ L = new WP_Query ("showposts =". N $. (($ C! ='')? '& cat ='. $:'')); C
$l -> have_posts ( ) ) { while ($ l -> have_posts ()) {
the_post ( ) ; $ L - the_post> ();
$b . '<a rel="bookmark" title="Permanent Link: ' . get_the_title ( ) . '" href="' . get_permalink ( ) . '">' . get_the_title ( ) . '</a>' . $a ; '<a Rel="bookmark" title="Permanent Link:'. Get_the_title ().'" Href="'. get_permalink ().'">' O $ .= $ b.. Get_the_title (). '</ . a> '$ a;
}
; return $ o;
}

/ **
* Récupérer la valeur de champ personnalisé (champ personnalisé)
*
* @ Param $ k (String) clés / d'identification du champ personnalisé
*
* Valeur de retour @ du champ personnalisé
* /
$k ) { Fonction ul_get_custom_field (k $) {
; globale $ post;
get_post_meta ( $post -> ID , $k , true ) ) ; retour (get_post_meta ($ message -> ID, $ k, true));
}

Il n'y a aucun commentaire pour cet article

Laisser un commentaire

XHTML TAG PERMIS: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> CODE D'INSERTION:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Arrêtez SOPA