Articles of hooks

WordPress Delete hook with wp_delete_post function?

I have this action/hook: add_action( ‘before_delete_post’, ‘my_delete_function’ ); function my_delete_function($post_id) { global $wpdb; $achievement = get_the_category($post_id); $h = $achievement[0]->cat_ID; $s = ”.str_replace(‘”‘, ”, $h); if ( $s == 6 || $s == 5){ $wpdb->query(“DELETE FROM wp_votes WHERE post = “.$post_id) or die(mysql_error()); } } The above works great when I am deleting posts from the […]

why does the add_action('the_content) overwrite my page

I am new to wordpress and I am trying to display some text on specific pages on my website. My problem is that my plugin replaces my current content on that page with the one on my plugin. How can I make the plugin not replace the content on the page. add_action( ‘the_content’, “displayNewsSlider”); function […]

is_search was called incorrectly

I created a search form which searching by category filter and keyword input. The search form code is here- <form action=”<?php bloginfo(‘url’); ?>” method=”get” role=”search” class=”dropdown-form”> <div class=”input-group”> <span class=”input-group-addon”> <?php wp_dropdown_categories(array( ‘show_option_all’ => ‘all categories’, ‘class’ => ‘search_cats’ )); ?> </span> <input type=”search” class=”form-control” placeholder=”<?php esc_html_e(‘Search anything…’, ‘onepro’); ?>” name=”s”> <span class=”input-group-addon”> <button type=”submit”><i […]

Filter or Hook to catch pre-rendering of post content

Is there a filter or hook that is triggered just before post content is rendered? What I’d like to do is to apply a filter to the text content of a post just before the post text is being rendered.

How to preserve edits to Name or Slug of term when using wp_update_term on save?

I am trying to insert content into a term’s description field on save. // insert stuff into description field of taxonomy function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){ // only insert content on certain taxonomies if ( $taxonomy === ‘some_custom_taxonomy’ ){ // unhook this function so it doesn’t loop infinitely remove_action(‘edit_term’, ‘insert_taxonomy_content’); $content = “Some Content”; […]

Is there an “Add Page” hook?

I’m looking for the action hook corresponding to the click on the “Add page” link. Any idea? Thanks !

How to override languages files in wp-content/languages/themes with child theme

I want to create a child theme for TwentyFifteen theme, which will customize a lot of things, including translation. When I install WordPress in my language (Farsi), it includes TwentyFifteen language files in wp-content/languages/themes So when I create a languages folder in my child theme and add customized language files to it and add load_theme_textdomain( […]

Good tools for locating hooks in a wordpress page/admin interface/blog post?

I’ve recently started using the Hikari Hooks plugin for WordPress as it seems to allow you to get a good idea of what do_actions are being called on the page, so that you can easily find out where potential hooks for plugin code might lie. Are there better tools/plugins for accomplishing the same thing? In […]

post meta data clearing on autosave

For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here: Custom field/meta populated by dropdown of existing posts? I am running into a problem however when wordpress auto saves itself, it clears […]

Hook up MU site creation

I want to write a plugin so I can hook up the wp_install_defaults function. I actually need to do the following: when a new site is created, I want to import a default XML file with some categories and default posts. wp_install_defaults is the function that does that, but it doesn’t seem to work. Isn’t […]