Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating custom options for "List-item" option in Option Tree #329

Closed
danielchikaka opened this issue May 15, 2014 · 6 comments
Closed

Creating custom options for "List-item" option in Option Tree #329

danielchikaka opened this issue May 15, 2014 · 6 comments

Comments

@danielchikaka
Copy link

Hey guys, I have a problem, I need to change the default options for a “List-item” option in Option tree . Right now the default are “Title/Image/Link/Descriptions” .. I want to remove them and add my own. I have written this code:

array(
  'id'          => 'academic_success_content',
  'label'       => 'Academic Success Content',
  'desc'        => 'Enter the academic success content. It will appear in the home page in list items format',
  'std'         => '',
  'type'        => 'list-item',
  'section'     => 'academic_perfomance',
  'settings'    => array( 
    array(
      'id'          => 'academic_success',
      'label'       => 'Academic Success',
      'type'        => 'textarea-simple',
    )
  )
)

but when i preview the themes options , the default list item "title" is still there and i only want to see the Academic Success textarea. What should i do?

@valendesigns
Copy link
Owner

@danielchikaka Your code looks correct. Unfortunately, the title is a required field for the List Item option type and you cannot remove it. However, you can replace the label and description with filters.

Example code:

/**
 * Filters the required title field's label.
 */
function filter_list_item_title_label( $label, $id ) {

  if ( $id == 'your_list_item_id' ) {

    $label = __( 'Content Title', 'theme-domain' );

  }

  return $label;

}
add_filter( 'ot_list_item_title_label', 'filter_list_item_title_label', 10, 2 );

/**
 * Filters the required title field's description.
 */
function filter_list_item_title_desc( $label, $id ) {

  if ( $id == 'your_list_item_id' ) {

    $label = __( 'Add a title only you will see. This makes it easier to drag & drop.', 'theme-domain' );

  }

  return $label;

}
add_filter( 'ot_list_item_title_desc', 'filter_list_item_title_desc', 10, 2 );

@ericbrockman
Copy link

How do you delete all options except the title? Just to make a simple list without any content or images, etc...

@valendesigns
Copy link
Owner

There is a filter you can use to filter the settings for a list-item type that will do what you want. I'm on my phone and don't know it off hand. I'll check when I get back in front of a computer.

@valendesigns
Copy link
Owner

@ericbrockman

function filter_ot_list_item_settings( $settings, $id ) {

  // Title only
  if ( 'your_option_id' === $id ) {
    return array();
  }

  return $settings;
}
add_filter( 'ot_list_item_settings', 'filter_ot_list_item_settings', 10, 2 );

@ericbrockman
Copy link

Thanks @valendesigns !

@ericbrockman
Copy link

Is it possible to add some of the fields and not others, I know the title is required, but how would you add say just the title and the image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants