Link to Second Level Admin Page

The add_submenu_page function allows you to link to a callback function and its this callback function which handles the display of that pages content. add_submenu_page( $parent_slug, //The slug name for the parent menu i.e. ppmtalentexpo $page_title, $menu_title, $capability, $menu_slug, $callback_function //your callback i.e. jwg_talentexpo_options2_page ); So far what you have appears right, assuming all your … Read more

Add post-new.php?post_cat=catslug to admin menu

To see the the current array keys try this: add_action( ‘admin_menu’ , ‘admin_menu_new_items’, 1 ); function admin_menu_new_items() { global $submenu; wp_die( ‘<pre>’ . var_export( $submenu[‘edit.php’], true ) . ‘</pre>’ ); } I get this: array ( 5 => array ( 0 => ‘All Posts’, 1 => ‘edit_posts’, 2 => ‘edit.php’, ), 10 => array ( … Read more

Displaying different custom post types under one admin menu

step 1: paste below code in your function.php (change the post_type) function house_a() { $args = array( ‘post_type’ => ‘house_a’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $returnvariable = “”; while ($my_query->have_posts()) : $my_query->the_post(); $returnvariabla .= get_the_content(); endwhile; return $returnvariable; } wp_reset_query(); … Read more

How to determin which admin screen/sub screen I’m currently viewing

Since admin menu itself knows how to display where you are at, it is reasonable to look at code responsible for that logic. Menu output is generated by _wp_menu_output() in menu-header.php. It makes use of number of global variables, namely: global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; The actual logic is quite extensive and naturally … Read more

How to add new tab to admin list of posts and handle result list

Admin post queries can be filtered just like frontend queries using pre_get_posts and checking for is_admin. add_action( ‘views_edit-post’, ‘remove_edit_post_views’ ); function remove_edit_post_views( $views ) { $views[‘pre’] = ‘<a href=”‘.admin_url().’edit.php?pre=pre”>My Special Posts</a>’; return $views; } add_action(‘pre_get_posts’, ‘my_special_list’); function my_special_list( $q ) { $scr = get_current_screen(); if ( is_admin() && ( $scr->base === ‘edit’ ) && $q->is_main_query() … Read more

WordPress add_options_page() function not considering role

Your understanding is incorrect. The third parameter to the add_options_page() function is Capability, not Role. This is made clear by the function’s prototype: function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = ” ) manage_options is a Capability. Administrator is not.

add function to saving change on Options Pages

To execute a task after a option has been updated, you can use updated_option action hook: add_action( ‘updated_option’, ‘updated_option_callback’, 10, 3 ); function updated_option_callback( $option, $old_value, $value ) { //Do something } Also, you can use update_option_{option-name} specifically for each option. For example: add_action( ‘update_option_new_option_name’, ‘update_new_option_name_callback’, 10, 2 ); function update_new_option_name_callback( $old_value, $value ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)