Automatically Updating Publish Date Bug

You could also hook into the save_{$post_type} action, which fires only when a certain post type is updated. This hook passes to post’s ID to the callback function: add_action( ‘save_post’, ‘my_callback_function’ ); function my_callback_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // Unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_callback_function’); // … Read more

Delete WordPress posts from URL list sql query

Yes you can. To delete posts with inherit post meta, use following code: DELETE p,pm FROM wp_posts p JOIN wp_postmeta pm ON pm.post_id = p.id WHERE p.post_name IN (‘post-1’, ‘post-2’, ‘post-3’) Pass slugs array to WHERE clause. If you want to delete only posts w/out postmeta (for some reason), use this code: DELETE FROM wp_posts … Read more

Query Posts multiple conditions

Try to use WP_Query as stated in this answer When should you use WP_Query vs query_posts() vs get_posts()?. $user_bids = array( ‘post_type’ => ‘post’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘duplicated’, ‘value’ => ‘0’, ‘type’ => ‘numeric’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘accept’, ‘value’ => ‘1’, ‘type’ => ‘numeric’, ‘compare’ … Read more

Remove all links in post content

Not sure about the database but you can do it easily with the_content filter, just add the code below to your current (child) theme functions.php file: add_filter( ‘the_content’, ‘misha_remove_all_a’ ); function misha_remove_all_a( $content ){ return preg_replace(‘#<a.*?>(.*?)</a>#is’, ‘\1’, $content); }

Avoid duplicate post from same Taxonomy

I see two ways to go about it, both quite similar. A) You can collect IDs of displayed posts in an array and then exclude those with post__not_in query parameter like so: $years_loop = get_terms( array( ‘taxonomy’ => ‘works_year’, ‘orderby’ => ‘slug’, ‘order’ => ‘DESC’, ) ); // array for displayed posts, we will update … Read more

Prepend or add an Image to the content of a Post

Heres a more simple version of your function: <?php add_filter( ‘the_content’, ‘theme_videos_append_image’ ); function theme_videos_append_image( $content ) { global $post; $upload_dir_arr = wp_upload_dir(); $static_image_url = $upload_dir_arr[‘baseurl’] . ‘/2017/11/upliftingscroll.jpg’; $tag = ‘<p><img src=”‘ . $static_image_url . ‘” alt=”” class=”img-responsive” /></p>’; return has_tag( ‘Videos’, $post->ID ) ? $tag . $content : $content; } ?> Check if that … Read more

Disable most recent & view all (TABS) on nav-menu.php

You can introduce a js file exclusively for admin panel doing this in functions.php: //Admin JS add_action(‘admin_init’, ‘custom_admin_js’); function custom_admin_js() { wp_register_script( ‘admin-js’, get_stylesheet_directory_uri() . ‘/js/admin.js’ ); wp_enqueue_script( ‘admin-js’ ); } And in admin.js file: jQuery(document).ready(function($) { $(‘*[data-type=”tabs-panel-posttype-page-most-recent”]’).fadeOut(); $(‘*[data-type=”page-all”]’).fadeOut(); $(‘*[data-type=”tabs-panel-posttype-page-search”]’).trigger(“click”); });

Getting a specific post values to another div or modal

You can do it in different ways: Json Encode This is my favorite way of passing data/settings/etc to the front-end. PHP $obj=array( ‘content’ => $post->post_content, ‘title’ => esc_html( get_the_title() ) ); Now the button output will be like this: HTML <button class=”btn btn-primary tag_cnt get_button_more_info” type=”button” value=”<?=json_encode($obj)?>”></button> Javascript (function($) { $(‘.get_button_more_info’).on(‘click’,function() { var obj = … Read more