Home › Forums › General Issues › Post Object: get_post_meta › Reply To: Post Object: get_post_meta
Hey James, let me clarify why I thought this might be related to ACF.
<?php
$post_object = get_field('film_session');
if( $post_object ):
// override $post
$post = $post_object;
setup_postdata( $post );
?>
<?php
$cr3ativconfmeetingdate = get_post_meta($post->ID, 'cr3ativconfmeetingdate', $single = true);
$confstarttime = get_post_meta($post->ID, 'cr3ativ_confstarttime', $single = true);
$confendtime = get_post_meta($post->ID, 'cr3ativ_confendtime', $single = true);
$confdisplaystarttime = get_post_meta($post->ID, 'cr3ativ_confdisplaystarttime', $single = true);
$confdisplayendtime = get_post_meta($post->ID, 'cr3ativ_confdisplayendtime', $single = true);
$cr3ativ_confspeakers = get_post_meta($post->ID, 'cr3ativ_confspeaker', $single = true);
/* ACF Fields Within Session */
$ticket_link = get_field('ticket_link');
?>
<div class="speaker_list">
<?php
$cr3ativ_confspeakers = get_post_meta($post->ID, 'cr3ativ_confspeaker', $single = true);
?>
<?php
if ( $cr3ativ_confspeakers ) {
foreach ( $cr3ativ_confspeakers as $cr3ativ_confspeaker ) :
/* What I had to hack for this to somewhat wark, but title must match */
$speaker = get_post($cr3ativ_confspeaker);
echo'<div class="speaker_list_wrapper">';
$speakerlink = sanitize_title_with_dashes($speaker->post_title);
echo '<a href=' . '/speaker/' . $speakerlink . '>';
echo get_the_post_thumbnail($speaker->ID). '<div class="redact redact__small">' . $speaker->post_title .'</div></a></div>';
/*-- End workaround
/* How it usually work on their templates
$speaker = get_post($cr3ativ_confspeaker);
$speakerlink = get_permalink( $speaker->ID ); // Permalink returning current page URL
echo'<div class="speaker_list_wrapper">';
echo '<a href="'. $speakerlink .'">';
echo get_the_post_thumbnail($speaker->ID). '<div class="redact redact__small">' . $speaker->post_title .'</div></a></div>';
*/
endforeach;
} ?>
</div><!-- End of speaker list -->
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
I thought maybe I was ending the post object call wrong?
Everything else works for the speakers list (thumbnail, post_title) just not the permalink.
Abe
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!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN
— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.