Allow public to post on blog

If you don’t want to give users access to the WordPress admin screens and you don’t want to use a premium plugin, you should create a form in a page and use wp_insert_post with the submitted data. In your case, the “post_status” parameter could be used to “moderate”: $post = array( ‘post_title’ => $_POST[‘title_field’], ‘post_content’ … Read more

WP_Query orderby not working with meta_value_num and menu_order

Found an answer to this. Somehow WordPress’ own orderby isn’t fully functional when trying to order by multiple values. I solved this by changing WP_Query to SQL Query, and including second DESC after _postmeta.meta_value+0 SELECT XXX_posts.* FROM XXX_posts INNER JOIN XXX_postmeta ON (XXX_posts.ID = XXX_postmeta.post_id) WHERE 1=1 AND XXX_posts.post_type=”sidebar_element” AND (XXX_posts.post_status=”publish”) AND (XXX_postmeta.meta_key = ‘sidebar_element_meta_alignment’ … Read more

How to modify post content?

You might check out the content_edit_pre filter. Your example would then look like this: function wpse89725_pre_edit_content( $content, $post_id ) { $content = “nothing”; return $content; } add_filter( ‘content_edit_pre’, ‘wpse89725_pre_edit_content’, 10, 2 ); You can read more about this filter in the Codex: https://codex.wordpress.org/Plugin_API/Filter_Reference/content_edit_pre Edit: You can also try the edit_post_content filter: add_filter( ‘edit_post_content’, ‘my_pre_edit_content’, 10, … Read more

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