Tag Info

New answers tagged

0

Using on_sent_ok as explained at contactform7.com/additional-settings can be very useful for adding some simple JavaScript like redirecting to another page. However it is rather prone to failing due to Javascript conflicts with either your current WordPress theme or one of the other plugins you are using. on_sent_ok is the absolutely last thing that runs ...


1

Ok figured it out. In the specific form settings, go to the additional fields tab. Type in the following: on_sent_ok: "location.replace('http://www.website-redirect.com');" It's working like a charm for me now. Hope this helps other developers in the future as well. I know the image is in Dutch ... but you can't miss it with the big red lines around the ...


1

Yes, there is a filter for this. The correct filter is wp_mail and is defined in /wp-includes/pluggable.php Line 135 So the code (maybe in your functions.php) should look something like this: function mail_template($args){ ob_start(); require_once (get_template_directory() . '/mail-templates/contacemail.php'); $args['message'] = ...


0

As an alternative, you can specify the Content-Type HTTP header in the $headers parameter: $to = 'sendto@example.com'; $subject = 'The subject'; $body = 'The email body content'; $headers = array('Content-Type: text/html; charset=UTF-8'); wp_mail( $to, $subject, $body, $headers );


0

Simply if(!is_home() && !is_front_page()) add_action( 'thesis_hook_after_post', 'my_related_posts' ); will do that for you. It will not do the add_action() when we are at the home page or not any front page. If it doesn't work for you, may be you need to contact with the Thesis team.


1

Does anyone know why this 'comment_post' hook doesn't seem to work!? ... When a comment is posted, the function is not triggered... at all? The hook works. Try the following, it works: add_action( 'comment_post', 'test_notify' ); function test_notify($args , $args2) { echo 'It works!'; die; } As does this: add_action( 'comment_post', ...


3

For the media library you can use the pre_get_posts hook targeting upload.php by means of $pagenow, a global variable, or even better, because globals are the devils child, by means of get_current_screen(). I'm assuming you want to target the media modal tab too - because targeting only one, but not the other, doesn't make much sense after all -, you can do ...


1

The earliest hook accessible from external code is muplugins_loaded. In order to use it, create a directory mu-plugins in your wp-content directory and put a PHP file into that directory. Sample code, will have side effects(!): add_action( 'muplugins_loaded', function() { print current_filter(); }); This is, of course, not "before anything else in ...


1

This will definitly remove word category . Add this code in functions.php.As you already know woocommerce_template_single_meta is the hook responsible for meta information of the single-product. File is present in /woocommerce/templates/single-product/meta.php. Either you can use the following code to edit the html of meta.php or you can copy the file ...


0

Child theme's can have their own header.php file, right? So why not just simply drop a child header.php file into the child theme's folder, then add the code there? Unless I'm missing something, this does seem to be the simplest solution.


0

All I can think is to process the posts at an earlier stage with a Core hook. This is crude, of course, but: function hack_the_post($posts) { foreach ($posts as $p) { $p->post_content .= ' I added this'; } return $posts; } add_action('the_posts', 'hack_the_post'); It is a bit energy intensive but so long as your plugin/theme uses more or less ...


0

Using below code you can directly redirect on home page when 404 call, please remove all code from the 404.php file and add below code. <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')); exit(); ?>


0

As was mentioned in a comment, template_redirect would be an appropriate hook for intercepting a 404 before the template is loaded. function wpd_do_stuff_on_404(){ if( is_404() ){ // do stuff } } add_action( 'template_redirect', 'wpd_do_stuff_on_404' ); Refer to the Action Reference for the general order of actions on the front end. The ...


2

You can use the set_user_role hook, that will only fire when the user role changes: add_action( 'set_user_role', function( $user_id, $role, $old_roles ) { // Your code ... }, 10, 3 ); If you want to restrict this to a profile update, you can use: add_action( 'set_user_role', function( $user_id ) { add_action( 'profile_update', function( ...


0

You are already echoing the data. Just use the_content(): echo '<div class="category-description"><p>',the_content(),'</p></div>'; Please note: those are commas not periods. echo will accept multiple parameters separated by commas and you will not see the odd results you get if you try to concatenate. The above is functionally the ...


0

... anything I find in core with either kses in the code or the PHP comments has to do with data sanitization? It would have to do with the functions that sanitize data or with data that needs to be sanitized, yes. That is the primary reason for the KSES code, which, if you look it over, is pretty resource intensive. You wouldn't want to use it ...


2

get_the_content do not apply the_content filter. You have to apply it after receiving contents like following <?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?> It is also detailed at the bottom of codex page


0

I wrote this plugin to do what you're asking - Simply Show Hooks. It shows you where all the action and filter hooks are, inline, in order, on the page you're looking at, and all the functions that have been hooked to them. Hope this helps :)


0

TL;DR: After the draft_to_publish hook is executed, the page is redirected, so you won't see the echoed output. Ref: http://wordpress.stackexchange.com/a/94011/71131 I think the problem is that the draft_to_publish action saves the post, which will call a redirect request to the browser, which loads the edit page from scratch again. Then whatever whatever ...


-1

Try to simply use ob in your function like so: add_action( 'draft_to_publish', 'my_hooked_function', 10, 10 ); function my_hooked_function( $post ) { ob_start(); echo '<script>console.log("some stuff to output to the developer console, via html page");</script>'; $output = ob_get_contents(); // Put ob content in a variable ...



Top 50 recent answers are included