Function in Child Theme not overriding Parent Theme function [duplicate]

First, you are confused. It is not the same “override a function” that remove a filter. Assuming that you want to remove a filter, I think that your code should be: function remove_html5_insert_image(){ remove_filter(‘image_send_to_editor’,’html5_insert_image’, 10); } add_action(‘after_setup_theme’,’remove_html5_insert_image’); Note that the filter tag and the priority argument in remove_filter must match the filter tag and the … Read more

Most elegant way to enqueue scripts in function.php with foreach loop

You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally. I would try something like this: (Untested and requires PHP5.4+) add_action( ‘wp_enqueue_scripts’, enqueue_scripts, 11 ); function enqueue_scripts() { /** * Build an array … Read more

how to create shortcode in wordpress

You can create your short code just few steps. function short_codeFunction_name( $atts, $content=null ) { shortcode_atts( array(), $atts); $rowin = ‘<div class=”row”>’.do_shortcode( $content ) .'</div>’; return $rowin; } add_shortcode( “your_shortcode_name”, “short_codeFunction_name” ); Then you can access [your_shortcode]Here your content[your_shortcode] format inside the Post,page etc. add this function inside function.php in active theme directory. use inside … Read more

How to override WordPress registration and insert an auto-generated username?

One alternative is to modify the $_POST[‘user_login’] input value when submitting new registration form, that is before WP process the registration form. A good hook to achieve this is login_form_register that fires before processing and rendering registration form. login_init also works but need more work to make sure we are on register action. add_action(‘login_form_register’, ‘custom_user_login’); … Read more

echo or print_r in an admin function

After the save_post hook is executed, the page is redirected, so you’re not able to see the print_r output. A simple method, if you can afford it, is to do a wp_die() just after the print_r or var_dump. Or you can check other debugging methods, like FirePHP.