Replace wordpress Content in PRE Tags with HTML Entities

May 26, 2010

If you have a website that often display some code on your wordpress, you know the important of converting PRE tag content to their HTML entities. Doing so prevents worlds of possible rendering issues. Just paste the following in your functions.php file. Once saved, it will automatically replace all content within <pre> and </pre> tags by html entities. //replaces pre content with html entities function pre_entities($matches) { return str_replace($matches[1],htmlentities($matches[1]),$matches[0]); } //to... [Read the full story]

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]

Automatically insert content after each wordpress post

April 7, 2009

Most wordpress blogs automatically displays some text after each post, for exemple to ask readers to subscribe to their rss feed of the blog. This text is very often hardcoded. Fortunately, we can using function.php instead, and be able to manage all in one place when  you’ll switch theme. Simply paste the following code in your functions.php file. By using functions.php, you’ll not have to re-insert this code if you switch themes. function insertFootNote($content) { if(!is_feed() && !is_home()) { $content.=... [Read the full story]

Display most popular content in wordpress sidebar

March 26, 2009

Highlighting the most popular posts on your site is a great way to send new visitors to your very best content and win them over. What about giving them a quick access to your most commented posts? There are a few different ways you can do this, and quite a few plugins out there to help. What we’re going to do is quite simple, we will set up a query to get an ordered list of your most commented posts from your database, and then display those any way we like. Setting this up as a sidebar widget is very easy. Just copy... [Read the full story]