Creating a Linktree-style page in WordPress

If you’ve ever wanted a straightforward way to display a list of important links on your WordPress site, you might find this useful! Using Advanced Custom Fields (ACF), we can create a Linktree-style page that’s both customisable and dynamic. This approach is particularly useful for social media bios, email signatures, or even simplified mobile navigation to get visitors into useful parts of your website or digial persona.

Why build a LinkTree-style page?

  1. Dynamic: Easily update links without touching the code.
  2. Customisable: Add icons, descriptions, and control link behaviour.
  3. Centralised: Keep all your important links in one place.

What You’ll Need

Step 1: Install ACF and Create Fields

Firstly, install the ACF plugin and create a new field group. Add the following sub-fields:

  • Link Name (Text)
  • Link URL (URL)
  • Icon (Text)
  • Open in New Tab (True/False)
  • Link Description (Text Area)

Step 2: Add PHP Code

Add the following PHP code to your page template where you want the links to appear.

<div class="quick-links mt-5">
  <?php
  if( have_rows('links') ):
    while( have_rows('links') ): the_row();
      $link_name = get_sub_field('link_name');
      $link_url = get_sub_field('link_url');
      $icon = get_sub_field('icon');
      $new_tab = get_sub_field('new_tab');
      $description = get_sub_field('link_description');
      $target = $new_tab ? 'target="_blank"' : '';
  ?>
  <!-- Your HTML markup here -->
  <?php
    endwhile;
  else:
    echo 'No links found';
  endif;
  ?>
</div>

Step 3: Add HTML Markup

Inside your PHP code, add the HTML structure for each link. You can also add classes for styling.

<div class="quick-link-item">
  <a class="quick-link-link mb-3" href="<?php echo $link_url; ?>" <?php echo $target; ?>>
    <?php if( $icon ): ?>
      <i class="fa-sharp fa-solid <? echo $icon; ?>"></i>
    <?php endif; ?>
    <?php echo $link_name; ?>
  </a>
  <?php if( $description ): ?>
    <p class="quick-link-description"><?php echo $description; ?></p>
  <?php endif; ?>
</div>

How to Extend

Here’s a few ways to extend what I’ve created and add your own flare and features.

  1. Multiple Groups: Create multiple ACF groups for different types of links (e.g., social, work).
  2. Conditional Styling: Use ACF to control the colour or size of each link.
  3. User-Specific Links: Make the links display conditionally based on user roles or activity. Hamdy for when you have dedicated-author pages and want to showcase some of their favourite links.

Creating a Linktree-style page with ACF in WordPress is simple but offers powerful customisation. It’s a dynamic, centralised, and easy-to-manage solution for showcasing important links on your site.

Photo by Tamanna Rumee on Unsplash

This post was written by James Kindred

Oh, hey! I’m James Kindred - a graphic designer in Suffolk, UK, and I run Fork: a creative consultancy for start-ups and scaling brands. With over 25 years of experience, I work with start-up and scale-up brands to develop their identity, collateral and brand strategy.

To top