- March 20, 2021 at 10:04 pm #32233
I’m trying to pull a custom field that is a group — a link and a file, one or the other is filled out always.
I want to build a button on the results page that will pull either the link when filled out or the file download right on to the results. this is how its working on the single-posttype.php file:
<?php if( have_rows('file_upload_or_direct_link') ): ?> <?php while( have_rows('file_upload_or_direct_link') ): the_row(); $file = get_sub_field('file_upload'); $url = get_sub_field('file_link'); if( $file ): ?> <a class="articleFileDownload" href="<?php echo $file['url']; ?>">Download PDF</a> <?php endif; ?> <?php if ($url): ?> <a href="<?php echo $url; ?>" class="outwardLinkArticle" target="_blank">Follow Link to Access document</a> <?php endif; ?> <?php endwhile; ?> <?php endif; ?>
any suggestions on how to incorporate this into the $r->content; or otherwise just pull it in to the results page?
thanks,March 22, 2021 at 1:01 pm #32243
Sure! Use the asp_results filter for that.Best,
Keep in mind, that it is not a posts loop, so you may have to change some of the functions there to pass the post ID argument via the
$r->idvariable in the foreach loop or use the setup_postdata function if that works.
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.