How to include styles and scripts on wordpress admin pages?
How do I add CSS and JavaScript to WordPress admin area? In “admin_enqueue_scripts” hook used to include scripts and css in admin area add_action(‘admin_enqueue_scripts’, function() { wp_enqueue_style( ‘myscript’, PTS_CSS_URL.’/myscript.css’); });
Page Template dropdown missing from page attribute in wordpress
Page Template dropdown missing from page attribute in wordpress: Either you are are added any page template or format is not correct while adding page template name It is because of space after the page template name: wrong code : <?php /* Template Name :Contact page // No need to add space here */…
How to add a logo uploading field in customize settings in wordpress
How to add a logo uploading field in theme customize settings in wordpress While creating our own theme, we need to add a logo adding field in in customize settings of theme (under appearance). add_action( ‘customize_register‘, ‘themecustomizer’ ); function themecustomizer( $wp_customize ) { $wp_customize->add_section( ‘theme_logo’ , array( ‘title’ => __( ‘Logo’, ‘theme’ ), ‘priority’ =>…
How to add a new page in wordpress admin
In functions.php file, Add following code add_action( ‘admin_menu’, ‘mycustompagemenu’ ); function mycustompagemenu(){ add_menu_page( __( ‘My own Settings’, ‘textdomain’ ), ‘my theme settings’, ‘customize’, ‘mythemesettings’, ‘my_theme_settings_fun’, get_template_directory_uri().’/images/icon.png’, 60 ); } function my_theme_settings_fun(){ esc_html_e( ‘Admin Page’, ‘textdomain’ ); } For more details add_menu_page()
Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet.
In WordPress themes showing error like : Broken Theme as below : Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet. This is because of your child theme missing, Template Name is missing from the style.css Add this line…
Display coupons used in an order in woocommerce
Use any order hooks. here we get the deatils of coupen once cancelled the order from orders list add_action(‘woocommerce_order_status_cancelled’, ‘order_cancelled_woo’); order_cancelled_woo($order_id){ $order = new WC_Order($order_id); $coupens= $order->get_used_coupons(); file_put_contents(‘filename1.txt’,print_r($coupens,true)); }
Ajax return 0 in wordpress
Use echo instead of return a value from ajax function . { echo ‘locked’; die(); }
How to add a new user meta field for all users in wordpress
$users = get_users(); foreach( $users as $user ) { $uid=$user->ID; add_user_meta($uid, ‘newfield’,’0′); } }
Adding a meta data once a new user is created in wordpress?
Add Custom User Meta During Registration in WordPress add_action( ‘user_register’, ‘bonus_point_for_new_user’); function bonus_point_for_new_user( $user_id ) { add_user_meta($user_id, ‘newfield’,’0′); }
Undefined message showing while new category adding?
Check whether is there any space before or after php opening and closing tag respectively in functions.php. If not deactivate each plugin and identify which plugin causes the issue, Then remove the extra space in that plugin after php closing tag.