How can I control if post updated

add below action in your main function file of your plugin add_action( ‘wp_insert_post’, ‘my_project_updated_post’, 10, 3 ); function my_project_updated_post( $post_id, $post, $update ) { // your code goes here // Every time you will get updated or newly created post id here. }

Reporting errors in a shortcode plugin

Take a look at admin notices. If you the cols parameter isn’t set use some code like this: function sample_admin_notice_fail() { ?> <div class=”notice notice-error is-dismissible”> <p><?php _e( ‘You forgot the cols parameter!’, ‘sample-text-domain’ ); ?></p> </div> <?php } add_action( ‘admin_notices’,’sample_admin_notice_fail’ ); to display this notice: on top of your admin page. You find some … Read more

How to delete all categories programatically?

Please have look on the below code block- $args = array( “hide_empty” => 0, “type” => “post”, “orderby” => “name”, “order” => “ASC” ); $types = get_categories($args); foreach ( $types as $type) { wp_delete_category( $type->ID ); } The function wp_delete_category will delete a single category. So we need to run a loop through $types to … Read more

WP Plugin with Upgrade option

If you want your plugin being hosted on WordPress.org Plugin Repository, you cannot combine Free and Premium version, in one plugin. You have to maintain two versions, Lite, hosted on WordPress.org, and Premium, hosted on your website. Plugins hosted on WordPress.org cannot make any remote requests to your website ( aka “calling home” ), therefore, … Read more

Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?

To override WooCommerce (WC) templates, put your modified templates in custom_theme/woocommerce/template-category/template-name.php Example: To override the admin order notification, copy: wp-content/plugins/woocommerce/templates/emails/admin-new-order.php to wp-content/themes/yourtheme/woocommerce/emails/admin-new-order.php WC Documentation Reference

Get post_id on clicking a link in WordPress

the another way to get the post_id by clicking on the link is to add a data-attribute to the link. e.g; data-post-id=”‘.get_the_ID().'” your html code should look like <a href=”#link” data-post-id=”47″>Link</a> then in your js code above the ajax call var post_id = jQuery(this).attr(‘data-post-id’); and pass this in your data object to the ajax call. … Read more