How to display max. 2 sticky posts when posts_per_page is 3?

Edit 2: Updated Code to account for “Maybe there are no stickied posts” 😉 Edit: I did a boo-boo with the number of posts. Fixed, should work now as intended. You can do this by using two queries. <?php //First, you get all the sticky posts $stickies = get_option(‘sticky_posts’,array()); //then, get max 2 of them … Read more

How to find the edit link of the WordPress Post from the URL

Yes, there is. You can use url_to_postid function: $postid = url_to_postid( $url ); It will give you ID of a post based on URL. So if you want to get edit link, then this will do exactly that: $postid = url_to_postid( $url ); if ( $postid ) { echo get_edit_post_link( $postid ); }

How do i search post by jquery datepicker?

I think it’s better to use date_query as argument, like so : $query = new WP_Query( ‘year=2012&monthnum=12&day=12’ ); or: $args = array( ‘date_query’ => array( array( ‘year’ => 2012, ‘month’ => 12, ‘day’ => 12, ), ), ); $query = new WP_Query( $args ); Source : https://codex.wordpress.org/Class_Reference/WP_Query

Display Specific Categories posts on the home page

function add_excluded_post_ids( $exclude_post_ids, $posts ) { foreach( $posts as $post ) { array_push( $exclude_post_ids, $post->ID ); } return $exclude_post_ids; } $exclude_post_ids = array(); $latest_posts = get_posts( array( ‘numberposts’ => 3 ) ); $exclude_post_ids = add_excluded_post_ids( $exclude_post_ids, $latest_posts ); $health_posts = get_posts( array( ‘numberposts’ => 3, ‘category’ => get_category_by_slug( ‘health’ )->term_id, // Change accordingly ‘exclude’ => … Read more