Support

Account

Home Forums Front-end Issues Button on front end website Reply To: Button on front end website

  • Add this to your single.php file where you want your button to appear:

    if (get_field('show_external_link_button')) { ?>
      <a class="post-button" href="<?php the_field('external_link_button_url') ?>"><?php the_field('external_link_button_label') ?></a><?php 
    }

    Remember that this code needs to be inside a PHP code block. This will create a link with external_link_button_label as the label and external_link_button_url as the target.

    To style the link as button add this snippet to your CSS file:

    .post-button {
      background-color: #4CAF50; /* Green background */
      color: white; /* White text */
      border: none; /* No border */
      padding: 15px 32px; /* Padding */
      text-align: center; /* Center the text */
      text-decoration: none; /* No underline */
      display: inline-block; /* Display on the same line */
      font-size: 16px; /* Increase font size */
    }

    You can play around with the values to match your website’s styles.