How to activate “Description” metabox for menu item programmatically?

Remove the description from the user meta value managenav-menuscolumnshidden: add_filter( ‘manage_nav-menus_columns’, ‘enable_nav_menu_description_by_default’ ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = ‘managenav-menuscolumnshidden’; $hidden = get_user_option( $desc_key ); $user_id = wp_get_current_user()->ID; if ( ! $hidden ) { update_user_option( $user_id, $desc_key, array ( 0 => ‘link-target’, 1 => ‘css-classes’, 2 => ‘xfn’ ) ); } elseif ( FALSE … Read more

How to add .htaccess code through a function?

/** * Inserts an array of strings into a file (.htaccess ), placing it between * BEGIN and END markers. Replaces existing marked info. Retains surrounding * data. Creates file if none exists. * * @param array|string $insertion * @return bool True on write success, false on failure. */ function add_htaccess($insertion) { $htaccess_file = ABSPATH.’.htaccess’; … Read more

Changing a function in function.php to a shortcode – for listing categories of only a certain post type

It looks like wp_list_categories($args) will output directly when you call it, which is why the output comes out in a weird place. and ideally what you need is to capture the output and return it, but luckily wp_list_categories allows you to do this with the ‘echo’ parameter. Try: $args[‘echo’] = FALSE; return wp_list_categories($args); Note the … Read more

How Can I Access a PHP Variable in Another PHP Function

G’day mate 😉 I’ve done this by outputting the variables within a script tag right within the body. I played around with your code and came up with this solution: function lax_google_map_init() { // Don’t bother loading the scripts if we’re in the admin area if ( is_admin() ) { return; } wp_enqueue_script( ‘google-maps’, ‘http://maps.googleapis.com/maps/api/js?sensor=false’ … Read more