New answers tagged

3

I'm not aware of any other way but to use both add_action lines, for a single function. Example: function my_enqueue_sripts_function_name(){ // your enqueue logic here } add_action('wp_enqueue_scripts', 'my_enqueue_sripts_function_name' ); add_action('admin_enqueue_scripts', 'my_enqueue_sripts_function_name' ); There's no rule that forbids ...


1

SOLUTION: We take this code and paste it to functions.php : function createit_hide_upd_for_other_adm_users() { $current_user = wp_get_current_user(); if ( 777 != $current_user->ID ) { //change the user ID add_filter( 'pre_site_transient_update_core', 'disable_updates' ); add_filter( 'pre_site_transient_update_plugins', '...


1

Thanks to rassoh for a nice option. Here is a revised version that contains a list of pages that should probably always stay at the top... /** * These 2 filters and 1 function move the built in WordPress admin pages to * the top so they don't get pushed down the menu every time a new plugin is installed. * Activates the 'menu_order' filter and then hooks ...


1

For all who have the problem just with Wordpress Blocks/Gutenberg, here is the solution I was looking for a long time. When you create a new taxonomy, make sure you've set show_in_rest to true. Otherwise it will not appear in Block editor. https://developer.wordpress.org/reference/functions/register_taxonomy/ Whether to include the taxonomy in the REST API. ...


0

This is old post but here is one universal function what working on the all WordPress versions. if(!function_exists('is_user')): function is_user ($role=NULL, $user_id=NULL) { if(empty($user_id)){ $user = wp_get_current_user(); } else { if(is_numeric($user_id) && $user_id == (int)$user_id) { ...


1

By looking at the source of the latest version, it shows that misc.php only gets included in one place at wp-admin/includes/admin.php. The include there is unconditional. That file in turn gets included seemingly unconditionally in wp-admin/admin.php, and this is required unconditionally as the first line in wp-admin/index.php. So it appears that it should ...


2

Looks like insert_with_markers() function becomes available during admin_init hook. So in order for your code to work, you should do the following: function do_my_htaccess_stuff_371705() { //function `insert_with_markers()` is working now } add_action('admin_init', 'do_my_htaccess_stuff_371705');


0

As per the requirement in the comments, one way to do that rewrite is with .htaccess. This may be possible with Wordpress rewrite functions too, but I find .htaccess easier as there are some constraints with the Wordpress functions. If your Wordpress installation is at http://localhost/wordpress then your .htaccess should be in the wordpress directory. Add ...


0

There's a filter called login_redirect where you can change the URL users get redirected to after logging in. There's a nice example in the comments of the documentation page here: https://developer.wordpress.org/reference/hooks/login_redirect/ Here's a suggestion of how you could modify it to do what you want: function wpdocs_my_login_redirect( $url, $...


1

WebElaine, if you are asking about global variable, i am doing something like this: global $total_len; ... function len_columns_content($column_name, $post_ID) { ... if ($length) { $total_len += $length; echo $length.' symbols'.'total: '.$total_len; } ... and in every string i have get $total_len equal $length, as if $total_len is not global


0

$parts = parse_url( admin_url() ); $url = "{$parts['scheme']}://{$parts['host']}" . add_query_arg( NULL, NULL );


Top 50 recent answers are included