the_post hook is not firing for me

Assuming that your post_meta is being properly added, that the post in question is a real post, and that the value of ‘nb_postredirect’ is a good URL, I’d try: function nb_checkredirect( $post ) { //don’t have to use get_post_meta!* if ( $post->nb_postredirect ) { wp_redirect( $post->nb_postredirect ); exit; } } add_action( ‘the_post’, ‘nb_checkredirect’ ); Tested … Read more

AMP – Change rel=”canonical” from functions.php [closed]

In general you can deregister the action’s callback, after it’s been registered and then register your own before it’s invoked with do_action( ‘…’ ). Here’s an example: // Add your own with later priority, e.g. 11 or wrap it in another later hook: add_action( ‘amp_post_template_head’, ‘wpse_amp_post_template_add_canonical’, 11 ); function wpse_amp_post_template_add_canonical( $amp_template ) { // Remove … Read more

Form action unfamiliar

Generally, they will return the same URL, as bloginfo( ‘url’ ) will call home_url internally with any arguments, and the default first argument ($path) of home_url is the empty string. However, bloginfo( ‘url’ ) will apply an additional filter to it, namely the home_url filter. Common pratice is to use home_url, indeed with esc_url (even … Read more

Filter for when the post is updated

The filter you are looking for is save_post. This filter is triggered each time you save a post. add_action( ‘save_post’, ‘my_function’ ); function my_function( $post_id ){ // Do your stuff here } This filter passes the post’s ID to the callback function, so you have access to everything you need.

Submit Form data to another page via Ajax (WordPress Way)

Modify the following code I have added action in it. $(‘#btnDoCalculation’).click(function(e){ var formData = $(‘#interest_calculator’).serialize(); $.ajax({ type: ‘POST’, url: ‘<?php echo admin_url(‘admin-ajax.php’);?>’, data:formData, dataType: ‘json’, action:calculate_investor_interest encode:true, }).done(function(data){ if(data.success){ console.log(data); var results = data.calc_results; var newData = results.reduce(function(collection, element){ var rowData = {}; //create a new empty row element.reduce(function(collection, element){ //put the elements into the … Read more

I can’t seem to install Font Awesome locally [closed]

Considering the folder structure “/public_html/wp-content/themes/TestTheme/static/fontawesome/” as folder location for Font Awesome use following instead 1 use following instead of the one you used for js include <script defer src=”https://wordpress.stackexchange.com/questions/299868/<?php echo get_template_directory_uri(); ?>/static/fontawesome/fontawesome-all.js”></script> 2 use following instead of the one you used for CSS include having fontawesome.min.css file in the CSS folder <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/299868/<?php echo … Read more

add_action template_redirect not working for home page

Be careful not to confuse the two query conditionals. Whether is_home() or is_front_page() return true or false depends on the values of certain option values. When using these query conditionals: If ‘posts’ == get_option( ‘show_on_front’ ): On the site front page: is_front_page() will return true is_home() will return true If assigned, WordPress ignores the pages … Read more