Create Menu on Theme Activation – WordPress

add_action(‘after_switch_theme’, ‘theme_activation_function’, 10 ,  2); function theme_activation_function ($oldname, $oldtheme = false) { /* Create header and footer menus */   $menus = array(     ‘Primary Menu’  => array(       ‘about-us’  => ‘About Us’,        ‘services’  => ‘Services’,        ‘templates-forms’  => ‘Templates & Forms’,        ‘clients’  => ‘Clients’,        ‘price-quote’  => ‘Price Quote’     ),   ‘Top Menu’ => array(     ‘home’ => ‘Home’,      ‘contact’ => ‘Contact’,      ‘sitemap’ => ‘Sitemap’   ),   ‘Footer Menu’ => array(     ‘terms-of-use’ => ‘Terms of Use’,      ‘privacy-policy’ => ‘Privacy Policy’   ) ); foreach($menus as $menuname => $menuitems) {   $menu_exists = wp_get_nav_menu_object($menuname);   // If it doesn’t exist, let’s create it.   if ( !$menu_exists) {     $menu_id = wp_create_nav_menu($menuname);     foreach($menuitems as $slug => $item) {       wp_update_nav_menu_item(       $menu_id, 0, array(             ‘menu-item-title’  => $item,             ‘menu-item-object’  => ‘page’,        … Continue reading Create Menu on Theme Activation – WordPress

Add custom javascript files to the wordpress site

Use wp_enqueue_script() in an init hook, or if in the admin only then in an admin_menu or admin_init hook. It might look something like this (which assumes you are calling from your theme’s functions.php file; note how I reference the stylesheet directory): <?php add_action(‘init’, ‘mysite_init’); function mysite_init() { $ss_url = get_bloginfo(‘stylesheet_directory’) wp_enqueue_script(‘mysite-scripts’,”$ss_url/js/mysite-scripts.js”); } That’s the basics. Pre-defined and Multiple Dependent Scripts But let’s say you… Continue reading Add custom javascript files to the wordpress site

Add Thumbnails in Manage Posts/Pages List wordpress

You can add this to your functions to display to the Manage/Edit Post and Pages List a new column with the thumbnail preview. /****** Add Thumbnails in Manage Posts/Pages List ******/ if ( !function_exists(‘AddThumbColumn’) && function_exists(‘add_theme_support’) ) { // for post and page add_theme_support(‘post-thumbnails’, array( ‘post’, ‘page’ ) ); function AddThumbColumn($cols) { $cols[‘thumbnail’] = __(‘Thumbnail’);… Continue reading Add Thumbnails in Manage Posts/Pages List wordpress

Change set featured image text within admin

Adding this snippet to the functions.php of your wordpress theme will change the “Set featured image” text to “Set default image” or what you would like. function custom_admin_post_thumbnail_html( $content ) {     return $content = str_replace( __( ‘Set featured image’ ), __( ‘Set Article image’ ), $content); } add_filter( ‘admin_post_thumbnail_html’, ‘custom_admin_post_thumbnail_html’ );