This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

custom field File or link type

Home Forums Product Support Forums Ajax Search Pro for WordPress Support custom field File or link type

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #32233
    mhmmdrzaei07mhmmdrzaei07
    Participant

    Hi there.

    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,

    #32243
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Sure! Use the asp_results filter for that.
    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->id variable in the foreach loop or use the setup_postdata function if that works.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.