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

  • Core Framework (54 posts)
  • Hybrid Theme (22,711 posts)
  • Bliss Theme (255 posts)
  • Options Theme (10,362 posts)
  • Visionary Theme (767 posts)
  • WordPress (144 posts)
  • WordPress Plugins (2,146 posts)
  • bbPress Themes (308 posts)
  • General Discussion (5,572 posts)
  • Critical Theme (0 posts)
  • Hybrid News Theme (132 posts)
  • Hybrid Original Theme (26 posts)
  • Leviathan Theme (16 posts)
  • Life Collage Theme (9 posts)
  • Old School Theme (3 posts)
  • Outline Theme (108 posts)
  • Skeleton Theme (40 posts)
  • Structure Theme (2,768 posts)
  • Members Plugin (2 posts)
  • Cleaner Gallery Plugin (14 posts)
  • Get the Image Plugin (3 posts)
  • Message Board Plugin (0 posts)
  • Widgets Reloaded Plugin (0 posts)
  • Breadcrumb Trail Plugin (0 posts)
  • Query Posts Plugin (80 posts)
  • Hybrid Hook Plugin (7 posts)
  • Hybrid Hook Widgets Plugin (0 posts)
  • Hybrid Tabs (5 posts)