Afficher les articles de la catégorie dans une page
2 réponses
- votes
-
- 2012-03-17
J'aifinalementtrouvé une solution depluginpourma deuxième option.J'utilisemaintenant Postspar chat et je le règle sur unnombreidiotpour quetoutdes articles de la catégorie s'affichent sur une seulepage;il s'avère que c'esttout ce dontj'avaisbesoin!
Merciet salutations
I found a plugin-solution eventually to the my second option. I now use Posts per cat and set it to some silly number so that all of the posts in the category display on one page; it turns out that's all I needed!
Thanks and Regards
-
- 2012-03-16
Commeje leferais:
D'abord - créez unepage dans l'admin wp. Créezensuite unfichier commemypage.php. Enregistrez-le dans votrethèmeet en haut de celui-ci,ajoutez cecipourindiquer à wordpress qu'il s'agit d'unmodèle depagepersonnalisé:
<?php /* Template Name: Custompage */ get_header(); ?>
Remarque:il appellera également déjà votreen-tête.
Insérezensuite unebouclepersonnaliséeen utilisant get_posts () comme ceci:
<?php global $post; // required $args = array('category' => 9); // include category 9 $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); // put here what you want to appear for each post like: //the title: the_title(); // an excerpt: the_excerpt(); //and so on... endforeach; ?>
Enfin,revenez à l'administrateuret dans les options de votrepage,vous devriez avoir unmenu déroulant dans laboîte "attributs de lapage". Sélectionnez lemodèle "Pagepersonnalisée" ou lenom que vous lui avez donné.
The way i'd do it:
First - create a page in the wp admin. Then create a file like mypage.php. Save it in your theme and a the top of it, add this to tell wordpress that this is a custom page template:
<?php /* Template Name: Custompage */ get_header(); ?>
Note: it'll also already call your header.
Then insert a custom loop using get_posts() like this:
<?php global $post; // required $args = array('category' => 9); // include category 9 $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); // put here what you want to appear for each post like: //the title: the_title(); // an excerpt: the_excerpt(); //and so on... endforeach; ?>
Then last, get back to the admin and in your page's options you should have a drop down menu in the "page attributes" box. Select the "Custompage" template or whatever name you gave it.
-
Désolépour la réponse lenteet mercipour le code.Cependant,pour une raison quelconque,celan'apasfonctionnépourmoi au débutet detoutefaçon,celam'a semblé unpeufastidieux de créer despageset de sélectionner lemodèle quej'ai,j'ai donctrouvé une solution quifonctionne avec lespages de catégorieexistantes (voirma réponse)... MerciencoreSorry for the slow reply, and thanks for the code. However for some reason it didn't work for me first off and anyhow, it seemed a bit tedious having to create pages and select the template I have, so I have found a solution that works with the existing category pages (see my answer)... Thanks again though
- 0
- 2012-03-17
- Andy
Je voudraispouvoir affichertous les articles d'une certaine catégorie sur unepage afin quetous les articles soient sur cette seulepageet qu'iln'y aitpas depagination.
Sipossible,je voudrais également afficher unbref aperçu des articles -tous les articles auront une vignetteet un courtparagraphe au début.
J'aiessayé différentsplugins,maisjusqu'àprésent,aucun de ceux quej'aitrouvésne fonctionne.
Est-ce que quelqu'un connaît unplugin ou unmoyen de lefaire?Alternativement,modifier lespages de catégoriespar défautpour qu'iln'y aitpas depaginationest une option sitout le reste échoue ...