Attaching image files to nodes programmatically in Drupal 7 – Stack Overflow

Attaching image files to nodes programmatically in Drupal 7 – Stack Overflow. $filepath = drupal_realpath(‘misc/druplicon.png’);// Create managed File object and associate with Image field. $file =(object) array(‘uid’=>1,’uri’=> $filepath,’filemime’=> file_get_mimetype($filepath),’status’=>1,);// We save the file to the root of the files directory. … Continue reading

custom post types – Highlighting wp_nav_menu Ancestor Class w/o Children in Nav Structure? – WordPress Development Stack Exchange

add_filter(‘nav_menu_css_class’, ‘current_type_nav_class’, 10, 2 ); function current_type_nav_class($classes, $item) { $post_type = get_query_var(‘post_type’); if ($item->attr_title != ” && $item->attr_title == $post_type) { array_push($classes, ‘current-menu-item’); }; return $classes; } This snippet allows you to check if the current menu item has a … Continue reading