How to show single post page as home page

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

How to allow logged in users to post anonymously

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

Limit popular posts by days

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’);

How to display posts on a static page? (like search loop)

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

delete_post hook – deleting multiple items

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.

Extracting post categories

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

Too many connections to server

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