This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT * | |
| FROM wp_posts | |
| WHERE post_title = "Mon titre d'article" | |
| AND post_status = 'publish' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| <?php if ( have_posts() ) : ?> | |
| <?php while (have_posts() ) : the_post(); ?> | |
| <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> | |
| <?php the_content(); ?> | |
| <?php endwhile; ?> | |
| <?php endif; ?> | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function add_my_widget() { | |
| register_widget( 'My_Widget' ); | |
| } | |
| add_action( 'widgets_init', 'add_my_widget' ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function my_notification_message( $message ) { | |
| $message .= 'Ceci est mon message personnalisé.'; | |
| return $message; | |
| } | |
| add_action( 'wp_mail', 'my_notification_message' ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function my_login_message() { | |
| global $current_user; | |
| $role = $current_user->roles[0]; | |
| if ( $role == 'administrator' ) { | |
| echo 'Bienvenue administrateur!'; | |
| } else { | |
| echo 'Bienvenue à vous!'; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function add_my_script() { | |
| wp_enqueue_script( 'my-script', get_stylesheet_directory_uri() . '/script.js' ); | |
| } | |
| add_action( 'wp_head', 'add_my_script' ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function mon_filtre_personnalisé($valeur) { | |
| // Modifier la valeur de la variable | |
| return $valeur; | |
| } | |
| add_filter('nom_variable', 'mon_filtre_personnalisé'); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function ajout_attribut_lien($text) { | |
| $text = preg_replace('/(<a.*?)(>)/','$1 target="_blank"$2',$text); | |
| return $text; | |
| } | |
| add_filter('the_content','ajout_attribut_lien'); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function mon_filtre_personnalisé($text) { | |
| // Ajouter le code à exécuter | |
| return $text; | |
| } | |
| add_filter('the_content', 'mon_filtre_personnalisé'); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Hook d'action : | |
| add_action('init', 'mon_hook'); | |
| function mon_hook() { | |
| // votre code ici | |
| } | |
| // Hook de filtre : | |
| add_filter('the_content', 'mon_filtre'); |