Articles of functions

get_page_templates only return templates with “home” in the filename

I have the following custom page template filenames: template-about-1.php template-about-2.php template-home-1.php template-home-2.php I have this function to get_page_templates: function get_page_templates_select() { $teh_cats = get_page_templates(); foreach ( $teh_cats as $template_name => $template_filename ) { $results[] = $template_name; } return $results; } How can I modify the function to ONLY return the templates that have “home” in […]

Overide Variable in Child Theme

I am trying to change the h1 tag in the head of my child theme from “Blog” to “Resources”. The parent theme enqueues files with require_once and get_template_directory so it’s very difficult to overwrite file through child theming. If anyone has a solution to that it would be great, but if not I thought I […]

Insert Content Before div#main from the functions.php File

I know WordPress has a filter for targeting the content in the functions.php file: add_filter( ‘the_content’) However, is there a filter to insert content BEFORE ? ‘the_content’ filter puts content AFTER div#main. I’m looking for something like: add_filter( ‘before_main’) Does a filter like that exist?

Warning: call_user_func() expects parameter 1 to be a valid callback, function

I keep getting this error when. I am trying to insert a dashboard widget and I don’t know what’s causing the error. Warning: call_user_func() expects parameter 1 to be a valid callback, function ‘voguepay_woocommerce_payouts_dashboard_widget_display’ not found or invalid function name in C:\xampp\htdocs\9ja\wp-admin\includes\template.php on line 1037 here is the code to add the widget public function […]

Where to store credentials used in a function?

This question already has an answer here: Where to securely store API keys and passwords in WordPress? 2 answers

Email Exists ERROR into Ajax registration form

My problem is that I can’t verify if some user insert an existing email into AJAX registration form. However my form is working fine, it’s registering users and it’s giving all other errors, like “invalid email” or “empty fields”. The only thing it doesn’t disaply is the error for the existing emails. function ajax_register(){ // […]

Redirects based on a JSON file

Having a JSON file, how can we set up WordPress to redirect the urls (if it’s found in the JSON file)? For example: { “foo”: “bar”, “foo-1”: “baz” } Then /foo will redirect to /bar and /foo-1 to /baz. What’s the best way to do this? Currently I do it with rewrite_rule in functions.php, but […]

Refresh page after form action

I’ve a listing post page where all posts are shown. On each post’s row I can perform actions like delete, archive etc. So imagine that: I have an “archive” button; I push on it and I get a modal (form) saying “Do you want archive this post?” Into the modal I have the submit button, […]

unnecessary request call for js and css after calling wp_dequeue_script

called unnecessary js and css request http://www.example.com/wp-content/plugins/includes/js/jquery.form.min.js http://www.example.com/wp-content/plugins/includes/js/scripts.js orignal it was http://www.example.com/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js http://www.serpentcs.com/wp-content/plugins/contact-form-7/includes/js/scripts.js this is happen after i written a function in function.php // below function is used to deque script on certain page function wpa_scripts() { // if this is not the contact page, remove the script if(!is_page(‘contact-us’) ){ wp_dequeue_script( ‘contact-form-7’ ); // only […]

Is it possible to use add_filter in an included file in the child theme's functions.php?

I am trying something basic but I can’t seem to figure it out or I am not even sure if it is possible to be done in a child theme. What is am trying is to organize the the codes in the functions.php file in the child theme by creating a separate directory for include […]