Home › Forums › Front-end Issues › relationship – impossible to get permalink › Reply To: relationship – impossible to get permalink
Hello,
i already use setup_postdata()
my complete function :
global $wpdb,$post;
$results = $wpdb->get_results( "SELECT * FROM wp_posts, <code>wp_mec_dates</code> AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND dstart>'$startday' and wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,5" );
if (count($results)> 0){
echo '<h3 class="widget-title"><span><i class="far fa-calendar-alt"></i> Les prochains événements</span></h3>';
foreach ($results as $post) {
setup_postdata($post);
$event_permalink = get_the_permalink();
$event_date = $post->dstart;
$new_event_date = date("d/m", strtotime($event_date));
$event_edate = $post->dend;
$new_event_edate = date("d/m", strtotime($event_edate));
$event_title = get_the_title();
$image_url = get_the_post_thumbnail_url('','liste-etablissements');
$event_cities = get_field('contact_city');
echo '<div class="events-sidebar"><div class="events-img">'."\n";
echo ' <a href="'. $event_permalink .'"><img src="'. $image_url .'" alt="" class="image"></a>'."\n";
echo ' </div>'."\n";
echo ' <div class="events-detail">'."\n";
echo ' <h3 class="presta-title"> <a title="" href="'.$event_permalink.'">'. substr($event_title,0,55) .'</a></h3>'."\n";
echo ' <div class="presta-decouvrir">'; if($new_event_edate != $new_event_date) { echo 'Du'; } else { echo 'Le'; } echo ' <b>' .$new_event_date; if($new_event_edate != $new_event_date) { echo '</b> au <b>'. $new_event_edate; } echo '</b><br />';
if($event_cities) { $cities = 0; $max_cities = 1; foreach($event_cities as $event_city) { $cities++; if($cities > $max_cities) { break; } echo 'à <a href="'. get_permalink( $event_city->ID ) .'" title="">'. get_the_title( $event_city->ID ) .'</a>'; } }
echo ' </div>'."\n";
echo ' </div></div><div style="clear:both;"></div>'."\n";
//echo $new_event_date . ' - <a href="'.$event_permalink.'" title="'.$event_title.'">' . substr($event_title,0,38) .'</a><br />';
}
}
wp_reset_postdata();
every data works, exept the relationship permalink.
if i deactivate my custom function in previous post, everything works well. But i don’t see in my function what is creating this trouble.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.