• Resolved orlafitz

    (@orlafitz)


    I am trying to add a custom field I’ve created to my single product page in WooCommerce.

    The field is a url – product_brochure

    Here is the action I am using:

    add_action( 'woocommerce_single_product_summary', 'poppy_pdf_brochure', 20);
    function poppy_pdf_brochure() {
        echo '<a href=" <?php the_field("product_brochure"); ?> " >Download The Brochure</a>';
    }

    But it won’t display it as a link. echo the_field(‘product_brochure’); is working but just displaying the full URL. I’ve tried so many different ways of doing this but just can’t figure out how to do it – would really appreciate anyones help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter orlafitz

    (@orlafitz)

    All delighted with myself that I figured it out – I wasn’t closing the php statement before starting the html! So the answer was:

    add_action( 'woocommerce_single_product_summary', 'poppy_pdf_brochure', 20);
    function poppy_pdf_brochure() { ?>
                    <a href="<?php echo the_field("product_brochure"); ?>" >Brochure</a>
    		<?php }

    Many people have been tripped up by a missing closing bracket! ??

    Hi Everybody.
    Is it possible to add a custom link to shop page or product page in woocommerce?
    This link has to show one item in my Zoomify Gallery.
    This link has to be only for registered users.
    Thanks a lot

    Or add an option in admin panel to set some link for each product that will be shown only for registered users ???
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add custom field link through functions.php’ is closed to new replies.