[Astuce] Ajouter un lien vers le sujet du forum

Toutes les documentations WordPress seront ici.
Verrouillé
Avatar du membre
Dakin Quelia
Webmaster
Webmaster
Messages : 565
Enregistré le : ven. 27 nov. 2009 05:47
Localisation : Belgique
Contact :

[Astuce] Ajouter un lien vers le sujet du forum

Message par Dakin Quelia »

» Ajouter un lien vers le sujet du forum

Vous souhaitez que vos commentaires soient remplacés par un lien vers le sujet de votre forum? Cette documentation va vous y aider.

Dans phpMyAdmin (ou tout autre logiciel de gestion SQL), vous devez exécuter cette requête SQL:

Code : Tout sélectionner

ALTER TABLE wp_posts ADD post_forum_url VARCHAR(255) NOT NULL DEFAULT ''
Cela donnera comme résultat:
  • Côté administration:
    Image
    Côté utilisateur:
    Image

Avatar du membre
Dakin Quelia
Webmaster
Webmaster
Messages : 565
Enregistré le : ven. 27 nov. 2009 05:47
Localisation : Belgique
Contact :

Re: [Astuce] Ajouter un lien vers le sujet du forum

Message par Dakin Quelia »

Ouvrez le fichier « /wp-admin/includes/post.php ».

Cherchez:

Code : Tout sélectionner

    $post_title = '';
    if ( !empty( $_REQUEST['post_title'] ) )
        $post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));  
Après, ajoutez:

Code : Tout sélectionner

    $post_forum_url = '';
    if ( !empty( $_REQUEST['post_forum_url'] ) )
        $post_forum_url = esc_html( stripslashes( $_REQUEST['post_forum_url'] ));  
Cherchez:

Code : Tout sélectionner

    $post->post_title   = apply_filters( 'default_title',   $post_title, $post   );  
Après, ajoutez:

Code : Tout sélectionner

    $post->post_forum_url  = apply_filters( 'default_forum_url',   $post_forum_url, $post   );  
Ouvrez le fichier « /wp-admin/edit-form-advanced.php ».

Cherchez:

Code : Tout sélectionner

<div id="titlewrap">
	<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
	<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
</div>
Après, ajoutez:

Code : Tout sélectionner

<div id="titlewrap">
	<label for="post_forum_url"><?php _e('URL du sujet forum') ?></label></label>
	<input type="text" name="post_forum_url" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_forum_url ) ); ?>" id="title" autocomplete="off" />
</div>

Avatar du membre
Dakin Quelia
Webmaster
Webmaster
Messages : 565
Enregistré le : ven. 27 nov. 2009 05:47
Localisation : Belgique
Contact :

Re: [Astuce] Ajouter un lien vers le sujet du forum

Message par Dakin Quelia »

Ouvrez le fichier « /includes/post.php ».

Cherchez:

Code : Tout sélectionner

        $format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password'); 
Remplacez par:

Code : Tout sélectionner

        $format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_forum_url', 'post_password'); 
Cherchez:

Code : Tout sélectionner

        'post_content' => '', 'post_title' => ''); 
Remplacez par:

Code : Tout sélectionner

        'post_content' => '', 'post_title' => '', 'post_forum_url' => ''); 
Cherchez:

Code : Tout sélectionner

    $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 
Remplacez par:

Code : Tout sélectionner

    $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_forum_url' 
Cherchez:

Code : Tout sélectionner

        'post_type' => 'page', 'post_status' => 'publish', 
Après, ajoutez:

Code : Tout sélectionner

        'post_forum_url' => '', 
Cherchez:

Code : Tout sélectionner

            'post_title' => __( 'Title' ), 
Après, ajoutez:

Code : Tout sélectionner

            'post_forum_url' => __( 'Lien Forum' ), 

Avatar du membre
Dakin Quelia
Webmaster
Webmaster
Messages : 565
Enregistré le : ven. 27 nov. 2009 05:47
Localisation : Belgique
Contact :

Re: [Astuce] Ajouter un lien vers le sujet du forum

Message par Dakin Quelia »

Ouvrez le fichier « /wp-content/themes/twentyten/loo.php ».

Cherchez:

Code : Tout sélectionner

                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
Remplacez par:

Code : Tout sélectionner

                <span class="comments-link"><?php if (!empty($post->post_forum_url)) { _e( '<a href="'.$post->post_forum_url.'">Sujet de discussion</a>', 'twentyten' ); } else { comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); } ?></span>

Verrouillé

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 2 invités