1 seule categorie sur ma home page

Résolu
help -  
 help -
Bonjour,
je voudrais afficher qu'une categorie sur ma page d'accueil.

Je n 'arrive pas a avoir qu'une seule categorie d'article sur ma page d'accueil....

version wordpress: la derniere
theme: voyage

2 réponses

  1. elgazar Messages postés 5776 Date d'inscription   Statut Membre Dernière intervention   1 330
     
    ajoute le code suivant dans le fichier functions.php de ton thème et n'oublie pas de modifier l'id de la catégorie (le 1 dans le code)

    function my_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( 'cat', '1');
    }
    }
    add_action( 'pre_get_posts', 'my_home_category' );
    0
  2. help
     
    <?php
    /**
    * Voyage Theme functions and definitions
    *
    * @package voyage
    * @subpackage voyage
    * @since Voyage 1.0
    */
    function my_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( 'cat', '8');
    }
    }
    add_action( 'pre_get_posts', 'my_home_category' );
    if ( ! defined( 'VOAYGE_THEME_VERSION' ) ) {
    define( 'VOAYGE_THEME_VERSION', '1.3.8' );
    }
    /** Run voyage_setup() after the 'after_setup_theme' hook */
    add_action( 'after_setup_theme', 'voyage_setup' );

    if ( ! function_exists( 'voyage_setup' ) ):
    /**
    * Sets up theme defaults and registers support for various WordPress features.
    * Note that this function is hooked into the after_setup_theme hook, which runs
    * before the init hook. The init hook is too late for some features, such as indicating
    * support post thumbnails.
    *
    * To override voyage_setup() in a child theme, add your own voyage_setup to your child theme's functions.php file.
    *
    * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
    * @uses register_nav_menus() To add support for navigation menus.
    * @uses add_editor_style() To style the visual editor.
    * @uses load_theme_textdomain() For translation/localization support.
    * @uses register_default_headers() To register the default custom header images provided with the theme.
    * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
    *
    * @since Voyage 1.0
    */

    function voyage_setup() {

    aucun effet ^^

    merci de la réponse :)
    0
    1. help
       
      https://wordpress.org/plugins/ultimate-category-excluder/

      est la solution simple. merci elgazar
      0