Skip to content
WordPress 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.

Wordpress 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-wordpress-field

Field initialization

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

return \GetOlympus\Field\Wordpress::build('my_wordpress_field_id', [
    'title'       => 'Which is your favourite post?',
    'default'     => [],
    'description' => 'Tell us which one did like this week.',
    'field'       => 'ID',
    'multiple'    => false,
    'type'        => 'post',
    'settings'    => [],

     * Texts definition
     * @see the `Texts definition` section below
    't_mostused' => 'Most used',
    't_search'   => 'Search',

Variables definitions

Variable Type Default value if not set Accepted values
title String 'Code' empty
default Array empty empty
description String empty empty
field String ID depends on type value
multiple Boolean false true or false
type String post see Accepted type
settings Array empty depends on type value


  • Set multiple to true to display checkboxes instead of radio buttons
  • field variable is used to let you retrieve the data you need, depending on type value (for example: in the 'type' => 'term' case, you'll get term_id by default)

Texts definition

Code Default value Definition
t_mostused Most used Used as a notice to help users to user multiselect field
t_search Search Used as a notice to help users to user multiselect field

Accepted type

Retrive data

Retrieve your value from Database with a simple get_option('my_wordpress_field_id', []) (see WordPress reference):

// Get wordpress from Database
$wordpress = get_option('my_wordpress_field_id', []);

if (!empty($wordpress)) {
    echo '<ul>';

    foreach ($wordpress as $post_id) {
        echo '<li>'.get_the_title($post_id).'</li>';

    echo '</ul>';

Release History

  • 0.0.16
  • FIX: bug on vars description
  • 0.0.15
  • FIX: remove twig dependency from composer
  • 0.0.14
  • FIX: remove zeus-core dependency from composer
  • 0.0.13
  • FIX: enhance display with an easier twig template

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.