Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

trying to hook into hybrid_post_meta_box_args

  1. Problem trying to list files that are in a directory within child theme and make as select box to choose one of them and have selection saved with the rest of the data.

    I have studied your hybrid_get_post_templates and can do something similar but
    but only outputting the drop down as normal with a quickly hurried together plugin not within yourmeta-boxes,

    Something along the line of

    function get_header_images() {
    $mythemdir = get_stylesheet_directory();
    
    $dhandle = opendir($mythemdir.'/images/headeraddons/');
    // define an array to hold the files
    $files = array();
    
    if ($dhandle) {
       // loop through all of the files
       while (false !== ($fname = readdir($dhandle))) {
          // if the file is not this file, and does not start with a '.' or '..',
          // then store it for later display
          if (($fname != '.') && ($fname != '..') &&
              ($fname != basename($_SERVER['PHP_SELF']))) {
              // store the filename
              $files[] = (is_dir( "./$fname" )) ? "(Dir) {$fname}" : $fname;
          }
       }
       // close the directory
       closedir($dhandle);
    }
    
    // Now loop through the files, echoing out a new select option for each one
    foreach( $files as $fname )
    
    return $fname;
    }

    But then how to get this to work with hybrid_post_meta_box_args

    I understand this is outside the scoop of normal support, but any directions or ideas greatly received...

  2. You must be a logged-in exclusive member to view this reply.

  3. Thats great!!

    Thank you, ok now off to work, I'm sure I'll be back soon...

  4. Well, I am sure that it was working, but now it does not remember the image....

    After choosing an image from the select box and then saving the post/page, once the edit page/post refreshes the select box is back to its default state blank

    Really strange... I have gone over the more recent code that I have been adding to functions.php and none of it refers to this and really just seems strange that it doesn't remember the chosen image

    Any ideas?

  5. You must be a logged-in exclusive member to view this reply.

  6. Sorry, should have stipulated more clearly.. here goes

    It does save the original Hybrid: Title Description, Keywords, Series, Thumbnail and newly added Page subtitle but not Header image or Menu title

    screenshot

    code being used

    add_filter( 'hybrid_page_meta_box_args', 'my_meta_box_args_pages' );
    add_filter( 'hybrid_page_meta_box_args', 'my_menu_box_args_pages' );
    
    function my_meta_box_args_pages( $meta ) {
    $images = get_header_images();
    if ( is_array( $images ) )
    		$meta['header_images'] = array( 'name' => 'Header Image', 'title' => __( 'Header image:', $domain ), 'type' => 'select', 'options' => $images );
    
    return $meta ;
    	}
    
    function my_menu_box_args_pages( $meta ) {
    
    $meta['menu_title'] = array( 'name' => 'Menu_title', 'title' => __( 'Menu title:', $domain ), 'type' => 'text' );
    $meta['Subtitle'] = array( 'name' => 'Subtitle', 'title' => __( 'Page subtitle:', $domain ), 'type' => 'text' );
    return $meta ;
    	}

    I have also tried returning back to the code as it was before ie without the addition of
    Menu title & Subtitle Just really get my head around this one...

  7. You must be a logged-in exclusive member to view this reply.

  8. Ok, so I can stop banging my head against the wall, thank you

    I just added an underscore and problem resolved...

    Makes me feel a lot better,
    can I suggest that when you have time* you add this to your tutorial clearly this

    *(I personally do not know where you manage to do everything that you do)

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Bliss Theme (198 posts)
  • Hybrid Theme (17,009 posts)
  • Options Theme (10,322 posts)
  • Structure Theme (2,624 posts)
  • Visionary Theme (767 posts)
  • bbPress Themes (293 posts)
  • WordPress Plugins (1,617 posts)
  • General Discussion (3,975 posts)