Articles of hooks

What's the difference between hooks, filters and actions?

This question already has an answer here: Difference Between Filter and Action Hooks? 3 answers

Dynamically Override Fancy Title

I’m trying to override Fancy Title created using The7 Theme. The7 Titles are generate from this function: function presscore_get_page_title() { $title = ”; if ( is_page() || is_single() ) { $title = get_the_title(); } else if ( is_search() ) { $title = sprintf( __( ‘Search Results for: %s’, ‘the7mk2’ ), ‘<span>’ . get_search_query() . ‘</span>’ […]

How can I send to multiple Contact Form 7 recipients based on form input?

We are running a competition whereby we need to send emails out to email addresses that are entered on a form. I’m using Contact Form 7 to do this. I thought this would be straightforward but the form will not accept the syntax of: [friend1-email], [friend2-email], [friend3-email], [friend4-email], [friend5-email] In the To or Bcc field. […]

How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks

We know that there is a certain order for the execution of callback functions attached to action hooks. How does WordPress decide which action should be prioritized while executing all the hooks?

Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: add_filter(‘the_content’, ‘say_hello’); function say_hello($content){ if(is_single() || is_page()){ print $content.” Thank you for reading!”; } else { print $content; } } But the following codes don’t seem to work: add_action(‘init’, ‘prepare_head’); function prepare_head(){ if(is_single() || is_page()){ // […]

Are posts updated or built from revisions + autosaves?

When editing a post in the admin I see records being added to the database to document my changes (here is part of the hooks I’m logging): … http://local.dev/151-autosave-v1/ clean_post_cache http://local.dev/151-autosave-v1/ transition_post_status http://local.dev/151-autosave-v1/ save_post Then when I click the “update” button and officially save my changes I see this: … http://local.dev/headers-page/ clean_post_cache http://local.dev/headers-page/ clean_page_cache http://local.dev/headers-page/ […]

Add custom classes to anchor in wp_nav_menu

I want to add a custom class to anchors in wp_nav_menu outputs. Default for example is: <li id=”menu-item” class=”menu-item menu-item-type-custom”> <a href=”http://example.com”>example</a> </li> I want this : <li id=”menu-item” class=”menu-item menu-item-type-custom “> <a href=”http://example.com” class=”class”>example</a> </li>

Please explain me what the do_action does

I am trying hard to understand do_action but not understanding. I was studying the blane theme. And they have this code in sidebar.php <div id=”secondary” class=”widget-area col-md-3″ role=”complementary”> <?php do_action( ‘before_sidebar’ ); ?> <?php if ( ! dynamic_sidebar( ‘sidebar-1’ ) ) : ?> <aside id=”search” class=”widget widget_search”> <?php get_search_form(); ?> </aside> <aside id=”archives” class=”widget”> <h1 […]

Receiving Stripe Webhooks on a wordpress website

I have a wordpress website hosted on GoDaddy. I am an advanced stripe user and have integrated stripe with many Ruby on Rails apps , along with stripe-webhook integration with the Rails. Also i am well versed in how web-hooks work. But recently i was made owner of a wordpress website hosted on GoDaddy and […]

Cast string to number

Actually, I am using pre_get_posts hook with these configure $metaquery = array( ‘relation’ => ‘OR’, array( ‘key’ => ‘price’, ‘value’ => array(80,100), ‘compare’ => ‘BETWEEN’ ) ); $query->set( ‘meta_query’, $metaquery ); However all the price values are saved under data type of string, so $query does not return the expected result because BETWEEN are treated […]