Skip to content
Link field, this component is a part of the Olympus Zeus Core framework.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Link Field

This component is a part of the Olympus Zeus Core WordPress framework.

Olympus Component CodeFactor Grade Packagist Version


Using composer in your PHP project:

composer require getolympus/olympus-link-field

Field initialization

Use the following lines to add a link field in your WordPress admin pages or custom post type meta fields:

return \GetOlympus\Field\Link::build('my_link_field_id', [
    'title'       => 'Never gonna give you up!',
    'default'     => [
            'url'    => '',
            'label'  => 'Never gonna get you down!',
            'target' => '_blank',
            'rel'    => 'nofollow',
    'description' => 'You\'ve been Rick rolled!',
    'multiple'    => false,

     * Texts definition
     * @see the `Texts definition` section below
    't_add_link'                 => 'Add link',
    't_delete_all'               => 'Delete all links',
    't_label'                    => 'Label',
    't_label_placeholder'        => 'Put your link label here.',
    't_relationship'             => 'Relationship',
    't_relationship_description' => 'You can set the <code>nofollow</code> value to avoid bots following the linked document.',
    't_target'                   => 'Target',
    't_target_blank'             => 'New window or tab',
    't_target_self'              => 'Same frame as it was clicked',
    't_target_parent'            => 'Parent frame',
    't_target_top'               => 'Full body of the window',
    't_website_placeholder'      => 'https:// or http://',
    't_website_goto'             => 'Go to',
    't_website_url'              => 'Website url',

Variables definition

Variable Type Default value if not set Accepted values
title String 'Hypertext link' empty
default Array empty empty
description String empty empty
multiple Boolean false true or false


  • Set multiple to true to enable the "Add link" button

Texts definition

Code Default value Definition
t_add_link Add link Used as a add link label button
t_delete_all Delete all links Used as a delete all links label button
t_label Label Used as a link label title field
t_label_placeholder Put your link label here. Used as a link placeholder title field
t_relationship Relationship Used as a link relationship title field
t_relationship_description You can set the nofollow value
to avoid bots following the linked
Used as a link relationship description field
t_target Target Used as a link target title field
t_target_blank New window or tab _blank target field description
t_target_self Same frame as it was clicked _self target field description
t_target_parent Parent frame _parent target field description
t_target_top Full body of the window _top target field description
t_website_placeholder https:// or http:// Used as a link website placeholder field
t_website_goto Go to Used as a link website go to label
t_website_url Website url Used as a link website label field

Retrive data

Retrieve your value from Database with a simple get_option('my_link_field_id', []) (see WordPress reference).
Below, a json_encode() example to understand how data are stored in Database:

  "1": {
    "url": "",
    "label": "",
    "target": "_parent",
    "rel": "dofollow"
  "2": {
    "url": "",
    "label": "",
    "target": "_blank",
    "rel": "nofollow"

And below, a simple example to show how to iterate on the data array in PHP:

// Get links from Database
$links = get_option('my_link_field_id', []);

// Check if links are empty
if (!empty($links)) {
    // Build HTML list
    echo '<ul>';

    foreach ($links as $link) {
        // Build HTML items
        echo '<li>';
        echo '<a href="'.$link['url'].'" target="'.$link['target'].'" title="'.esc_html($link['label']).'">';
        echo $link['target'];
        echo '</a>';
        echo '</li>';

    echo '</ul>';

Release History

  • 0.0.15
  • FIX: remove twig dependency from composer
  • 0.0.14
  • FIX: remove zeus-core dependency from composer
  • 0.0.13
  • FIX: add wp-util integration to make JS works fine

Authors and Copyright

Achraf Chouk

Please, read LICENSE for more information.


  1. Fork it (
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time.

You can’t perform that action at this time.