Author Link in Recent Posts Widget

I think the rather simplistic approach would be: copy the whole WP_Widget_Categories from wp-includes/default-widgets.php, and paste it to your functions.php. In there, you could modify the output by customizing this part of the class: class WP_Widget_Recent_Posts extends WP_Widget { … <?php echo $before_widget; ?> <?php if ( $title ) echo $before_title . $title . $after_title; … Read more

shortcode for recent custom type post

This seems to work with custom post type : function get_custom_posts( $params ) { extract( shortcode_atts( array ( ‘number’ => ‘1’, ‘excerpt’ => 290, ‘readmore’ => ‘no’, ‘cpt’ => ‘post’, ‘readmoretext’ => ‘Read more’ ), $params ) ); //$latest_posts = get_posts( ‘category=0&numberposts=” . $number . “&suppress_filters=false’); OLD $latest_posts = query_posts( ‘post_type=”.$cpt.”&posts_per_page=” . $number ); wp_reset_query(); … Read more

How to display posts on template

$args = array( ‘posts_per_page’=>-1, ‘number_posts’=>-1, ‘category’=>9, ‘orderby’=>’post_date’, ‘order’ => ‘DESC’, ‘post_type’=>’post’, ‘post_status’=>’publish’ ); $posts = get_posts($args); foreach($posts as $post): $id= $post->ID; $permalink = get_permalink( $id ); $title = $post->post_title; $content = $post->post_content; $image = wp_get_attachment_url(get_post_thumbnail_id($id)); endforeach;

Show recent posts in single-post page

The function get_posts() accepts a parameter ‘post__not_in’, which allows you to specify an array of post IDs to exclude from the query. get_posts() is just a wrapper for WP_Query, so the documentation for this parameter can be found here. When inside the loop (such as inside single-events.php) you can retrieve the current post’s ID with … Read more

Have latest post and recent posts display differently

You need 2 queries e.g. $query1 = new WP_Query( ‘post_type=post&posts_per_page=1’ ); // The Loop while ( $query1->have_posts() ) { $query1->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } wp_reset_postdata(); $query2 = new WP_Query( ‘post_type=post&posts_per_page=100&offset=1’ ); while( $query2->have_posts() ) { $query2->next_post(); echo ‘<li>’ . get_the_title( $query2->post->ID ) . ‘</li>’; } wp_reset_postdata(); The first query gets the first … Read more