Articles of recent posts

Create static front-page with 3-5 recent posts

I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the Underscore boilerplate. As I understands, the codex suggests that I create a front-page.php and customize it there. In setting>reading I selected A static/Front page (my desired page where I change the […]

Show recent published posts

I want to list recent published posts of my wp blog and exclude certain posts of some categories. The following code works fine, 10 recent posts are listed and posts in the listed categories are ignored. However, draft posts are listed as well. $args = array( ‘numberposts’ => ’10’, ‘tax_query’ => array( ‘post_type’ => ‘post’, […]

Recent Posts widget without Title

I want to add “Recent Posts” widget in a sidebar without a title but every time I add it, it shows “Recent Posts” text as title. How do I have it without title? I don’t want to use any plugin for this. Thank You.

How to get most recent commented post above new submitted post in WordPress?

I have this function: $ids = $wpdb->get_col(“SELECT DISTINCT comment_post_ID FROM $wpdb->comments ORDER BY comment_date DESC LIMIT 0 , 30″); foreach ($ids as $id) { $post = &get_post( $id ); setup_postdata($post); ?> <p><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></p> <?php } ?> Which shows the latest commented posts in a […]

Two posts are loaded instead of one?

I am trying to add a read posts function to my WordPress website. To achieve this, I create a cookie on which I store all the IDs of read posts. Every time a post is loaded, the following function is fired : function readPosts() { if (is_single()){ $postId = get_the_id() . “/”; $cookie = empty($_COOKIE[‘readposts’]) […]

Grabbing specific content

Right now I’m doing this (pseudo code) posts = content_type(“special_stuff”); $i = 0; $n = 5; $while(have_posts) { if($i == $n) { // print the content } ++$i; } This is what I’m doing to always get the nth item. I’m sure there is a better way, but I’m kind of a WP noob. Related: […]

Add inline HTML to posts published within last 24hrs

Basically I’m looking to add this line of code to posts published within the last 24hrs: <span class=”new”>New!</span> When the post is over 24hrs old, remove the inline HTML element. This is my code so far but have no idea how to implement this feature, anybody got any ideas? <section class=”post-wrap”> <ul class=”filter”> <li><a href=”<?php […]

How can I show recent posts from same taxonomy as the post currently being viewed?

I’m wondering how I can show recent posts from the same taxonomy as the post that’s currently being viewed (working with custom post types and custom taxonomies). If it was simply a category of a regular post, it would look like this: <?php global $post; $categories = get_the_category(); foreach ($categories as $category) : ?> <h3>More […]

What's the difference between “get_posts” and “wp_get_recent_posts” when used with “setup_postdata”?

This might be a completely “I’m still new to WP” type question, but I ran into some interesting output when using get_posts() and wp_get_recent_posts() in a custom function I wrote with setup_postdata(). Here’s what I had in my functions.php file: <?php function getRecentPosts($total_posts = 2) { $total_posts = intval($total_posts); global $post; $args = array( ‘posts_per_page’ […]

customizing recent posts

Im working on my first wordpress blog and trying to avoid plugins if at all possible for a lot of what doesn’t really need to have a plugin. I am slightly familiar with php ( I don’t understand it but I know where to put it and what file should go where). I understand the […]