• Let me start at the beginning. Forgive me, as I am not well versed in PHP, and tend to take more of a stumbling, smash-and-grab approach to the language.

    Here’s what I’m trying to do:

    I have a conditional statement that displays buttons to download a file using an echo, provided a post from a certain category is being shown. What I need to do is have the href to one of the buttons be taken from a custom field (in this case, “direct_download_link”) from that post. Here’s the code I’m trying to use to accomplish this:

    <?php 
    
    if ( in_category( 'Episodes' )) {
    
    echo '<a href="<?php echo get_post_meta($post->ID, 'direct_download_link', true); ?>"><img src="/images/download-button_01.png"></a><img src="/images/download-button_02.png"><br><br>';
    
    } 
    
    ?>

    Of course, this isn’t working, because the php inside of the echo isn’t getting parsed, it’s just printing to the browser.

    The page in question is here: https://anchor-consulting.com/dev/bionic/?p=559

    Can anyone help me, or offer a better suggestion for accomplishing what I am trying to do?

    Thank you very much

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter ultramalcolm

    (@ultramalcolm)

    Yes, the custom field for the download link is filled in. I just tried adding it to a second page in the “Episodes” category: https://anchor-consulting.com/dev/bionic/?p=569

    The results were the same…the button is showing the address of the page itself, not the value of the custom field.

    When I add a plain <?php the_meta(); ?> , I do get the list of meta data. (I left it in so you can see.)

    Any other ideas?

    thanks for leaving the control output in your site.

    your custom field output is showing this key:

    direct_downoad_link

    see (or rather not see) the missing letter l in download ?

    seems to be case of a simple typing mistake …

    Thread Starter ultramalcolm

    (@ultramalcolm)

    AUUUUUUUUUUUUUUUGH!

    Thank you SO SO much for being a second set of eyes on this. I appreciate it very much.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Calling a custom field inside of an echo?’ is closed to new replies.