Support

Account

Forum Replies Created

  • Hi skdsam 🙂 !

    Thanks a lot !! I modify a little the code but I get what I want :).
    And even if I didin’t give you a lot of elements, you have gone in the good limb :D.

    Here is the code I use from yours:

    $args =array(
    	'orderby' => 'post_date' , 
    	'post_type' => 'post' , 
    	'meta_key' => 'utilisateur_lie', 
    	'meta_value' => $profil_ID,
    	'posts_per_page' => 1
    );
    	$query = new WP_Query($args);
    
    	if ($query->have_posts()) :
    	while ($query->have_posts()) : $query->the_post(); update_post_caches($posts);
    		echo'<p><b>Découvrir son histoire :</b> <a href="'.get_permalink().'">'.get_the_title().'</a></p>';
    endwhile;
    endif;
    wp_reset_postdata(); 

    And here is some more informations:
    On my website, In my fields groups I’ve created a field group “User infos” where I’ve added two custom fields (a ‘Select: “shop”, and a ‘Select’:”town”).
    They “appear” when I add or edit users profiles.

    Then I’ve created an other fields group : “User post” where I have added a field “User” (named ‘utilisateur_lie’) who “appears” when I create/edit a post in a specific category (“Stories”) to link a post to a user.
    So now favor to your code I’m able to display the story belonging to that user :).
    That’s really great !

    Now, can I ask you something more complex?
    Will it be possible to retrieve and display a list of posts “linked” to a shop (for which several users work). A kind of grouping post by shop.

    I will really be very grateful if you could help me with this problem ;).

    Anyway, thanks a lot for your time and your help skdsam 😀 !!

    Have a great day 🙂 !!

    Amicably,

    Pierre.

Viewing 1 post (of 1 total)