rss

Controlling custom content areas on your site

9 Apr, 2008 Page

Most of the time when you’re designing a home page for a CMS based website, you’re going to have specific areas of content on your page that aren’t blog related, but that you want your client to have control over. For example their contact details, an ‘about us’ blurb, their company motto or maybe their company’s vision. There exists a really easy way in WordPress to allow for these areas to be controlled through your admin.

As the above example shows, we have a ‘Projects’ area as well as a ‘random quote’ area to the right. These actually 2 ways that you can accomplish this – either as a page or as a post.

First question you’d need to ask is, “Is that content area going to change often, or will it remain mostly static?” In the case of the former, your best best would be to accomplish this as a blog post.

Using blog posts

Firstly, create a category that will be used for entering these random quotes. If you do not want this information to form part of your company blog etc, then you’ll want to exclude that particular category from your normal listings. This can be done by simply adding &exclude=9 to your WordPress category query.

<? wp_list_cats('sort_column=name&optioncount=0&exclude=9'); ?>

Then on your page where you want this information to appear, you’d call it like this:

<? query_posts('cat=9&showposts=1'); ?>
<? if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- LOOP STUFF HERE -->
<? endwhile; endif; ?>

Additionally, you can also add orderby=rand() to bring in a random quote on each page reload.

Using pages

If however, the content you’re wanting to display will hardly change, like a company vision statement or contact details, then you can simply create a custom loop that brings in the content from that 1 specific page.

<? query_posts('page_id=2'); ?>
<? if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- LOOP STUFF HERE -->
<? endwhile; endif; ?>

In this way, you’ll display just that particular content area and your or your client will be able to update this information as & when they need to.

4 Comments

  1. вы гомики ???

  2. Вы допускаете ошибку. Предлагаю это обсудить. Пишите мне в PM.

  3. Вы не правы. Предлагаю это обсудить. Пишите мне в PM, поговорим.

  4. Очень понравился ваш блог! Подписался на rss. Буду регулярно читать.

Leave a Reply

About The WordPress Guru

Over the last 4 or 5 years, I’ve been digging into the Wonders of WordPress. From the days when the Classic theme was the shizz until now, WordPress has gone from strength to strength both as the blogging platform of choice for many big players and as a CMS with...

Learn more »