Support

Account

Home Forums Front-end Issues Display ACF Field in Raw HTML Code

Solving

Display ACF Field in Raw HTML Code

  • Hi,

    I have a URL Field in ACF with the name of citation_pdf_url. This contains the PDF link to the document of each post and I need to display a button in the post to Download PDF and fetch the URL from citation_pdf_url. I am using tagDiv Composer of Newspaper 11 theme. However, I am not able to get the output of the button using the ACF field.

    I have used this HTML Code

    <!DOCTYPE html>
    <html>
    <head>
    <title>Title of the document</title>
    <style>
    .button {
    background-color: #1c87c9;
    border: none;
    color: white;
    padding: 20px 34px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 20px;
    margin: 4px 2px;
    cursor: pointer;
    }
    </style>
    </head>
    <body>
    Click Here
    </body>
    </html>

    But the output is not downloading the file, as this href code is not printing the acf value.

    I also tried these values in ahref field:

    [acf field="citation_pdf_url"]
    get_field(citation_pdf_url)
    $the_field=”citation_pdf_url
    $get_field(citation_pdf_url)
    <?php the_field(‘citation_pdf_url’); ?>

    But not working.

    Please help me. How can i use acf value in Raw HTML as that is the only option to create and display a button.

  • <body>

    Click Here [ I am intentionally using this, the editor is linking it as Click here]

    </body>

  • An ACF file field has these return types: File Array (array), File URL (string), or File ID (integer).

    ACF will not automatically output a link to the file. You must create this yourself. For example if the return type is URL then

    
    $url = get_field('citation_pdf_url');
    ?><a href="<?php echo $url; ?>">Click Here</a><?php 
    
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.