How do I exclude the current post from listing in recent posts
The post__not_in arg should work for you: $args = array( ‘numberposts’ => 5, ‘offset’ => 0, ‘category’ => 7, ‘post__not_in’ => array( $post->ID ) ); $myposts2 = get_posts($args);
The post__not_in arg should work for you: $args = array( ‘numberposts’ => 5, ‘offset’ => 0, ‘category’ => 7, ‘post__not_in’ => array( $post->ID ) ); $myposts2 = get_posts($args);
It depends on what theme you use as they are not coded the same. Use pre_get_posts or the reading settings and the_content() rather than the_excerpt() in your loop. function wpsites_home_page_limit( $query ) { if ( $query->is_home() && $query->is_main_query() && !is_admin() ) { $query->set( ‘posts_per_page’, ‘1’ ); } } add_action( ‘pre_get_posts’, ‘wpsites_home_page_limit’ ); Or you could … Read more
In order to do what you are asking, there first needs to exist an anonymous user. Assuming this user exists, there are just a few steps: 1) modify the comment form to include the anonymous check box. 2) detect whether the box is checked. 3) if the box is checked, use the comment_save_pre filter to … Read more
Here is a function which show the posts of last 7days or you can change it according to your requirement. function filter_where($where=””) { //posts in the last 7 days $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-7 days’)) . “‘”; return $where; } add_filter(‘posts_where’, ‘filter_where’);
You could use query_posts() to set up a new loop in your page. Assuming that the posts you want are in the category ‘Noticias’, with a slug of ‘noticias’: query_posts( ‘category=noticias’ ); if( have_posts() ) { get_template_part( ‘loop’, ‘index’ ); } wp_reset_query(); // probably not necessary, if you don’t have a pre-existing Loop
Caveat, I can’t really test this right now. However, there are several things that I think could be improved from your code. First if we read the codex or some tips on using ajax we can setup an ajax callback function that isn’t pointing to a file where we have to bootstrap the WordPress load … Read more
That’s not how that hook is meant to be used: do_action( ‘delete_post’, int $postid, WP_Post $post ) https://developer.wordpress.org/reference/hooks/delete_post/ The action gives you the post ID and a post object. So don’t access $_GET or the global $post object, instead use the what the action gives you.
Check to see if you have a post ID (which you should on a single post page but I am not sure if this is in single.php or some other template like index.php) and add that to the $args if you do. $args = array( ‘numberposts’ => 3, ‘orderby’ => ‘rand’ ); if (is_singular() && … Read more
WordPress has a table called *wp_term_relationships* to keep track of several types of relationships, including post – category. Let’s go table by table: wp_posts – holds all posts,pages, and other content. You want to poll all rows that have -> post_type = post . You might want to poll only published posts -> post_status = … Read more
I contacted my hosting provider to solve this problem and they claim that my wordpress is generating too many simultaneous connections to server… The only times I’ve seen hosts put limits on the number of MySQL connections is when the host is free or very cheap or incompetent. Is it free hosting? It’s really easiest … Read more