Update custom settings field in plugin

Your code is saving the option, but your input field is not actually displaying the option’s value because you’ve used the wrong option name, which is url_field_name and should instead be webhook_url_field_name (the second parameter value for register_setting()). So the correct HTML would be: <!– I wrapped the value attribute for brevity –> <input type=”url” … Read more

Get Menu Items from REST API (React)

getMenu() fetches data from the GET /wp/v2/menus/<id> endpoint, whereas getMenuItem() fetches data from the GET /wp/v2/menu-items/<id> endpoint, but they have the same usage syntax, where you just need to pass the ID of a menu or menu item. As for getMenuItems() and another function you can use — getMenus(), the endpoints are GET /wp/v2/menu-items (for … Read more

How do I cycle a JS function in WordPress? [closed]

Rather than trying to include jquery with your javascript, you should use wordpress to define jQuery as a dependency to your custom script. function custom_js_script_enqueue(){ wp_enqueue_script( ‘mycustomjs’, CHILD_THEME_URI . ‘/assets/js/my-custom-js.js’, array(‘jquery’), ‘1.0.0’ ); } add_action(‘wp_enqueue_scripts’, ‘custom_js_script_enqueue’); you can read about all of the libraries available in wordpress here. Your script should not include the jquery … Read more

Call pre_get_posts inside ajax

Not the way you’re doing it, no. When the pre_get_post action is run any WP_Query queries run will be modified by the callback. Actions are not persistent, so when you run add_action() inside an AJAX callback that action is only going to be applied for that request, and you’re not running any queries in the … Read more

Remove automatic excerpts only for single posts

It seems to me that your code runs too early, i.e. before WordPress determined what the queried object is, i.e. whether it’s for a single post, a category archive, a search results page, etc. Such issue could happen if you added the code “just like that” to your theme’s functions file, so try doing it … Read more

New WP installation on Hostgator domain but not working

If you followed the process here, then it’s really down to hostgator to see you right and work with you to remedy, given it’s offered as a one-click install option through their cpanel. That said, i’d be inclined to the follow what’s said here first. https://www.hostgator.com/help/article/error-messages-during-one-click-wordpress-install And if you’re still getting nowhere trying again with … Read more

Filter and manipulate the get_current_user() function

From what I’m seeing in the github repo. get_current_user doesn’t exist. What you do have is wp_get_current_user, this function does this return _wp_get_current_user(); So now I checked what _wp_get_current_user does. It checks a global variable $global_user, if it’s not empty, return an instance of it (didn’t find any actions for that). If empty it does … Read more

WooCommerce: I Need to hide my page title/header (including menu) from all the WooCommerce related product pages, such as category and keyword pages

Take a look at the body class tags. This will help you further define your CSS selectors to target the elements you want to hide. In this use case, you can a single CSS rule to hide the header on each and every woocommerce page. Here is what I would use in your case .woocommerce … Read more

Creating custom link that redirects to a another link

First, create a page with the intended URL slug and note down the ID of it. Then in your functions.php function wpse410694_custom_redirect() { //Let us assume the ID of the page is 123 if ( is_page(123) ) { wp_redirect( ‘drive.google.com/myCustomPDF_Link’ ); exit; } } add_action( ‘template_redirect’, ‘wpse410694_custom_redirect’); The maximum upload size is normally set from … Read more

notify users when changed database

I don’t want Ajax request to be sent every 2 seconds. Is there a way to send me a notification only if the database changes in a certain meta? You can’t watch the database for changes like this. The most you could do is add filters on post meta changes on the PHP side to … Read more