Comment afficher les articles de l'utilisateur / auteur actuel dans un modèle de page personnalisé?
2 réponses
- votes
-
- 2011-07-23
cela devraitfonctionnerpour vous:
if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array('posts_per_page' => '-1','author' => $current_user->ID); $author_posts = new WP_Query($author_query); while($author_posts->have_posts()) : $author_posts->the_post(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; else : echo "not logged in"; endif;
this should work for you:
if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array('posts_per_page' => '-1','author' => $current_user->ID); $author_posts = new WP_Query($author_query); while($author_posts->have_posts()) : $author_posts->the_post(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; else : echo "not logged in"; endif;
-
- 2014-10-16
Pourinclure l'heure depublicationpersonnalisée dans letableau
$author_query array
,ajoutez un autre élémentkey=>value
autableau$author_query array
.Exemple:
$author_query = array( 'posts_per_page' => '-1', 'author' => $current_user->ID, 'post_type'=>'your custom post type name' );
To include custom post time in the
$author_query array
, add anotherkey=>value
element to$author_query
array.Example:
$author_query = array( 'posts_per_page' => '-1', 'author' => $current_user->ID, 'post_type'=>'your custom post type name' );
-
Bienvenue à WPSE.Juste quelquesnotespour vous aider à démarrer: 1.) Expliqueztoujours correctement ce quefait votre codeet commentilfonctionne 2.) Veuilleztravailler sur votreformat de code lors de l'ajout de code.Si vous ajoutez du code,mettez-leen surbrillance dans l'éditeur de codeet cliquez sur le signe `{}` au-dessus de l'éditeur.Je vous remercieWelcome to WPSE. Just a few notes to get you started: 1.) Always properly explain what your code does and how it works 2.) Please work on your code format when adding code. If you add code, highlight it in the code editor and click on the `{}` sign above the editor. Thank you
- 0
- 2014-10-16
- Pieter Goosen
J'essaie de créer untableau debord comme unmodèle depagepersonnalisé qui répertorie lespublications de l'utilisateur actuellement connecté.J'aiessayé detrouver une solution sur lenet.mais aucunn'était approprié