Using wordpress shortcodes to show members-only content

May 14, 2009

This tutorial will cover three methods for setting up shortcodes to use in your posts and pages that will allow you to hide or show content depending on who’s viewing it. Content for users that are not logged in Many people want to focus on hiding content from this group of users, but you want to start by showing them content. Most traffic to your site will likely be through non-logged in users, so make sure you give this group of people something. Open your theme’s functions.php file in your favorite text editor. Add... [Read the full story]

Replacing WordPress content with an excerpt without editing theme files

May 14, 2009

Let’s suppose our front page and archives used the WordPress function <?php the_content(); ?> to retrieve all post content. Let’s further suppose we’re want to modify this with a child theme to show excerpts instead of the entire post. We could easily just change <?php the_content(); ?> to <?php the_excerpt(); ?>. But, We don’t want to edit the core files at all. We want to be able to upgrade our theme without our modifications being broken. The Solution is: WordPress filters. In our child theme’s... [Read the full story]

Return wordpress posts for various date ranges

May 14, 2009

WordPress loop is very powerful, as well as the query_posts() function, which allow you to specify some parameters for the loop to retrieve posts. Though, there’s no built-in function or parameter to return posts for various date ranges. Open your index.php file and find the loop. Just before the loop starts, paste the following code. Of course, don’t forget to change the dates according to your needs. <?php function filter_where($where = '') { //posts in the last 30 days //$where .= " AND post_date > '"... [Read the full story]

Show Wordpress Posts With a Specific Custom Field and Value

May 14, 2009

Ever wanted to be able to only get the list of wordpress posts which have a specific custom field key as well as a specific value? Sometimes you only want to show wordpress posts that you’ve added a specific custom field to. For instance, lets say you write wordpress host and wordpress template reviews and for each you give them a custom field “review_type” with the value set to either “url” or “template”. So how would you show posts that are only wordpress template reviews? Simply... [Read the full story]

Page 2 of 2«12