Prevent loading of functions

I’ll assume add_css and add_js are wrappers for wp_enqueue_style and wp_enqueue_script. As such, the way you register any style / script is through either wp_dequeue_style and wp_dequeue_script, where you pass the handle of the scripts. See: https://developer.wordpress.org/reference/functions/wp_dequeue_script/ Now, from that code alone, it doesn’t seem like he’s passing any handles to these “register” functions, so … Read more

How to insert class in each list of categories?

Why don’t you use get_categories instead. Here is an example: $categories = get_categories(); $output=””; if($categories) { $output = “<ul class=”list-inline”>”; foreach($categories as $category) { $output .= ‘<li class=”list-inline-item”><a href=”‘.get_category_link( $category->term_id) . ‘”>’.$category->cat_name.'</a></li>’; } $output .= “</ul>”; } echo $output; Head over here for more available modification options

Way to redirect all Product Sub Category to its Main category Page?

You will have to use JS for the redirection since header is already sent before we can check the category, following snippet would do the work: add_action(‘woocommerce_before_main_content’,’redirect_to_top_level_parent’,1); function redirect_to_top_level_parent(){ if (is_product_category()){ $cate = get_queried_object(); $cateID = $cate->term_id; $parentcats = get_ancestors($cateID, ‘product_cat’); $count = count($parentcats); if ($count > 0){ $count = $count-1; $link = get_term_link( $parentcats[$count], … Read more

Add a field into a shortcode of an extension

to customise the complete result of the shortcode, you can try this code which redefine the shortcode : add_action(“plugins_loaded”, function () { if (!isset($GLOBALS[“shortcode_tags”][“wpneo_crowdfunding_form”])) { return; } $original_callback = $GLOBALS[“shortcode_tags”][“wpneo_crowdfunding_form”]; add_shortcode( “wpneo_crowdfunding_form” , function ($attr, $content, $tag) use ($original_callback) { $original_result = $original_callback($attr, $content, $tag); // customise the HTML result of the form $original_result = … Read more

Check if a value exists in database table

Replace this: $result = $wpdb->get_row(“SELECT * FROM wp44_predefined_address WHERE ‘UPPER(Address1)’ LIKE ‘UPPER(%s)'”, $myinput); with this: (just choose the appropriate $like based on your requirements) // Properly generate the LIKE query. $like=”%” . $wpdb->esc_like( $myinput ) . ‘%’; // e.g. ‘%input%’ //$like=”%” . $wpdb->esc_like( $myinput ); // e.g. ‘%input’ //$like = $wpdb->esc_like( $myinput ) . ‘%’; … Read more

Native gallery custom html output

Is this what your looking for, here? get_post_gallery_images(). This is the example for that page. add_filter( ‘the_content’, ‘wpdocs_show_gallery_image_urls’ ); /** * Show image URLs below the content */ function wpdocs_show_gallery_image_urls( $content ) { global $post; // Only do this on singular items if( ! is_singular() ) return $content; // Make sure the post has a … Read more

400 Bad Request – JavaScript App calling Custom wp-json endpoint

There were three problems I discovered with my code above. First, $_SERVER[“HTTP_REFERRER”]; is an undefined index, moreover it is mispelled – HTTP_REFERER would be correct if it could be accessed this way in WP. I found get_http_origin() instead. $data[‘UrlReferer’] = get_http_origin(); Second, I also mispelled the field I was saving this variable to – UrlReferrer … Read more

Redirect to other page if login

Add below code in your functions.php file of active theme directory in order to restrict the login page to logged-in users and redirect them to core user page (user profile). You can replace “um_get_core_page( ‘user’ )” with any page URL where you want to redirect logged-in users. /* Restrict Login page to logged-in users and … Read more

Add attribute only to first image of every post via functions.php

add_filter( ‘the_content’, ‘wpse317670_add_img_attribute’ ); function wpse317670_add_img_attribute( $content ) { $from = “https://wordpress.stackexchange.com/”.preg_quote(‘<img’, “https://wordpress.stackexchange.com/”).”https://wordpress.stackexchange.com/”; $to = ‘<img example=”example”‘; return preg_replace($from, $to, $content, 1); } This will add the example=”example” to the first image found in every post content. There is another option, without using regular expression (possibly much faster and will use less memory): add_filter( ‘the_content’, … Read more