wp_is_mobile dequeue not working

It looks like you are using the script “src” rather than the script “handle”. Have you tried: add_action( ‘wp_enqueue_scripts’, ‘remove_plugin_scripts’, PHP_INT_MAX ); function remove_plugin_scripts() { if ( wp_is_mobile() ) { // Remove script file. wp_dequeue_script( ‘tp-tools’ ); wp_deregister_script( ‘tp-tools’ ); wp_dequeue_script( ‘revmin’ ); wp_deregister_script( ‘revmin’ ); } }

Replace menu links with # and add name to its li

I want the URLs of the nav-items to be replaced with # You can use the nav_menu_link_attributes hook to set the custom href value like so: add_filter( ‘nav_menu_link_attributes’, function ( $atts, $item, $args ) { if ( ‘menu-categorias’ === $args->theme_location && ‘category’ === $item->object ) { $atts[‘href’] = ‘#’ . get_term_field( ‘slug’, $item->object_id ); } … Read more

Redirect specific page in WordPress for first time visit

I would always hook it to template_redirect. Something like this: add_action( ‘template_redirect’, ‘custom_check_for_redirect’ ); function custom_check_for_redirect(){ global $wp_query; # It could work without this too! if( is_page( 8219 ) ) $days_to_expire = 30; if (!is_admin() && !isset($_COOKIE[‘already_visited’])) { setcookie(‘already_visited’, true, time() + 86400 * $days_to_expire); wp_redirect(home_url(‘/welkom’), 302); exit; }; };

is_account_page() change to page slug

You could try to use the is_page() function – https://developer.wordpress.org/reference/functions/is_page/ The function signature accepts one parameter – $page (int|string|int[]|string[]) (Optional) Page ID, title, slug, or array of such to check against. Default value: ” if ( is_page(‘account’) ){ // do some code here }

Custom HTML in specific category single page and its descendant categories

A few changes to your code: Changed the action hook to wp_head. Removed the false ‘pluggable’ wrapping of your function. if ( ! function_exists( ‘post_is_in_descendant_category’ ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $cat, … Read more

wp_get_attachment_image function size argument not working if I also add a custom class

Just as Tom mentioned in the comments above. The fourth parameter of wp_get_attachment_image sets the value, not adds to it so it will override the auto generated class. If you need the size class and your custom class you can simply add both of them manually like so… echo wp_get_attachment_image( $image_id, ‘image-size’, ”, [ ‘class’ … Read more

Enqueue scripts not working with if is page conditional tag in functions.php

Try doing in the opposite way. Add_action can always be active, and add the if statement into the function. Like this: add_action(‘wp_enqueue_scripts’, ‘insert_mapsvg_scripts’); function insert_mapsvg_scripts() { if( is_page( 37629 ) ) { wp_enqueue_style( ‘mapsvg_css’, site_url(‘/mapsvg/css/mapsvg.css’) ); wp_enqueue_style( ‘nanoscroller_css’, site_url(‘/mapsvg/css/nanoscroller.css’) ); wp_enqueue_script( ‘mousewheel_js’, site_url(‘/mapsvg/js/jquery.mousewheel.min.js’), array(‘jquery’), ”, true ); wp_enqueue_script( ‘nanoscroller_js’, site_url(‘/mapsvg/js/jquery.nanoscroller.min.js’), array(‘jquery’), ”, true ); wp_enqueue_script( … Read more

post to subcategory and parent in wp_insert_post

The problem is, you can’t make an array like that in PHP. Trying to cast a string that contains a comma separated list as an array just produces an array with a single value–your comma separated string. You want to use php’s explode function to create the array. It takes a string an splits it … Read more