How Can i Get 5 Recent Post Title With Corresponding Link?

I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie …. 2 Answers 2 This sounds like an additional Loop on that page, right? You might want to use: <ul> <?php $posts_query = new WP_Query(‘posts_per_page=5’); while ($posts_query->have_posts()) : $posts_query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/20489/<?php the_permalink(); … Read more

how to programmatically change post tags

Is there a php function which can add/remove tags of posts? If not how would I do this? I am looking for something like this: add_tag($post_id, ‘tag-name’); remove_tag($post_id, ‘tag-name’); 1 Answer 1 The key function you’re looking for here is wp_set_post_tags(). To add the tag ‘awesome’ to post 98, wp_set_post_tags( 98, array( ‘awesome’ ), true … Read more

posts_per_page doesnt work

Here is the my custom query ; <?php $Poz = new WP_Query(array( ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘no_found_rows’ => true, ‘update_post_term_cache’ => false, ‘update_post_meta_cache’ => false, )); // The Query $the_query = new WP_Query( $Poz ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/70424/<?php the_permalink(); ?>” title=”<?php … Read more

Group posts by year in loop

How can I separate posts by year in archive page for Custom Post Type? while ( have_posts() ) : the_post(); the_title(); the_post_thumbnail(‘thumb’); endwhile; The end result would look something like this: 2016 – Title1 – Title2 – Title3 – Title4 2015 – Title1 – Title2 – Title3 – Title4 etc. 1 Answer 1 This little … Read more

publish_post hook isn’t working for scheduled posts

I had a bit of an issue with wp-to-twitter publishing a tweet linking to a post that was set as ‘pending’ that i had emailed to my wordpress.org site. The email included a footer, which included my mobile number. I decided to create my own plugin. add_action(‘publish_post’, ‘tcr_tweet’); /* the function */ function tcr_tweet($postID) { … Read more