-
Author
-
October 5, 2015 at 01:13 #80842costa974Participant
I have a custom post type “painting” and it is user generated.
Then a menu “My paintings”
How can I display only the posts/paintings of the current logged user?
Thanks
October 5, 2015 at 03:29 #80849sharmstrModeratorYou should read this: http://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/ Especially the Querying Custom Post Types section. Then you can read this for all the arguments you can pass to wp_query https://codex.wordpress.org/Class_Reference/WP_Query
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
October 5, 2015 at 03:30 #80850sharmstrModeratorSorry, hit submit too soon. Finally, read this to get the current user id https://codex.wordpress.org/Function_Reference/get_current_user_id
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
October 5, 2015 at 03:42 #80854costa974ParticipantI see… but can I do it with the Visual Composer or I have to code something?
Don’t you have an example?
ThanksOctober 5, 2015 at 03:45 #80855sharmstrModeratorYou cant do it with VC. You need to code it. Examples are in the links I gave you. Its all wordpress stuff and not Kleo specific.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
October 5, 2015 at 19:55 #80986costa974Participantadd_shortcode(‘pitturo_my_gallery’, ‘pitturo_my_gallery_shortcode’);
function pitturo_my_gallery_shortcode() {
$args = array(
‘post_type’ => ‘painting’,
‘post_status’ => ‘publish’,
‘author’ => get_current_user_id()
);$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
get_template_part(‘page-parts/post-content-masonry’);
}
}wp_reset_query();
}it works, but the layout is broken… ho can I reuse the kleo masonsry template?
October 6, 2015 at 00:47 #81022sharmstrModeratorYou havent add the masonry divs so it has no idea what to do
COPY CODEif ($query->have_posts()) { echo '<div class="posts-listing responsive-cols kleo-masonry per-row-3 with-meta masonry-listing">'; while ($query->have_posts()) { $query->the_post(); get_template_part('page-parts/post-content-masonry'); } echo '</div>'; }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.