• Resolved aminfri

    (@aminfri)


    Hi, (this plugin is really awesome and i have a range of feature requests ?? )

    Is there a method where i can get the meta info on the front end?

    For example in my template i say something like this:

    get_meta_info(PLACE META ID HERE);
    like:
    get_meta_info(‘picture’);

    And it returns an array with this information:

    label, type, description

    What i want to do is to show the label on the front end and then the meta value. But i want it to be dynamic so whenever i change the label in back end i dont have to change my template files too.

    https://www.ads-software.com/plugins/optiontree-metabox-ui/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter aminfri

    (@aminfri)

    I noticed this little nice function in the source code that returns the label:

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    function ot_get_meta_label( $id ) {
      if ( empty( $id ) )
        return false;
      $settings = get_option('rj'.ot_settings_id());
      if ( empty( $settings['settings'] ) )
        return false;
      foreach( $settings['settings'] as $setting ) {
        if ( $setting['id'] == $id && isset( $setting['label'] ) ) {
          return $setting['label'];
        }
      }
    }

    This can be used to retrieve the description field as well:

    function ot_get_meta_desc( $id ) {
      if ( empty( $id ) )
        return false;
      $settings = get_option('rj'.ot_settings_id());
      if ( empty( $settings['settings'] ) )
        return false;
      foreach( $settings['settings'] as $setting ) {
        if ( $setting['id'] == $id && isset( $setting['desc'] ) ) {
          return $setting['desc'];
        }
      }
    }

    Hope that helps a fellow dev.

    Plugin Author Rajilesh Panoli

    (@rajilesh)

    I have add more functions to get settings data.
    Please checkout the Documentation for more info

    https://yourdomain.com/wp-admin/admin.php?page=rj-ot-documentation

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get meta info on front end’ is closed to new replies.