5 Quick Useful Wordpress Tips

5wptips

Wordpress is a great Content Management and Blog solution for a web development platform when used correctly.

Wordpress can give you a great code platform and foundation for a CMS and Blog functionality, but of course you can tweak Wordpress to your own specific needs and add a few nice little features to your custom designed themes.

1) Add a submenu for your page.

If you would like a section on a page theme for a submenu generated from the back-end pages then the following code will build you an unordered list menu of sub pages..

<div id="submenu">
<ul>
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<?php echo $children; ?>
<?php } ?>
</ul>
</div>

2) Create page theme layouts.

If you want a significantly different layout for a specific page, then it may be worth using a different template rather than incorporating various condition statements and layouts into your page template. This is actually really easy to do, simple copy your default page template, rename it newname.php and at the top of the page before your header call place the following comments…

/* Template Name: newname
*/

3) Create custom headers.

If you need to have a different header design and layout then you can create and call a separate header file template. Simply copy your default header file to a file called (for example) header-newname.php,  now replace your call to the header file in the template page with …

 get_header("events");

4) Display category specific posts

When you need to display specific category posts somewhere on your site you can do that using the query_posts functions and passing conditions.

$cat_name = 'category_name';
$cat_name = str_replace(' ','-',$cat_name);
query_posts('category_name='.$cat_name."&showposts=1");
 while ( have_posts() ) : the_post()
...

Where show posts is of course the number of posts you wish to display.

5) Call Random Post

If you want to display a random post from a category then similar to above you use query posts, however you will also add orderby …

query_posts('category_name=testimonials&showposts=1&orderby=rand');

Now each time the page loads you will get a different post appear.

I hope these quick tips helped, if you have any questions please feel free to ask.

1 Comment

  1. Tweets that mention 5 Quick Useful Wordpress Tips | Scotchegg website development -- Topsy.com
    October 19, 2009

    [...] This post was mentioned on Twitter by Ivor, scotchegg / Pete. scotchegg / Pete said: 5 Quick but very useful Wordpress tips! http://bit.ly/4gPHC [...]

Post Comment

Upcoming web training classes

Introduction to HTML and Web Standards

15th / 16th April : Fazeley Studios – Birmingham

This course is perfect for anyone new to web development who wishes to learn and begin to understand what really goes into making a website.

What we do

  • Website Design
  • Website Development
  • Logo Design
  • Print Media
  • Flash Animations
  • Website SEO
  • E-Commerce
  • Photography
  • Website Hosting

quick quote

Why not send us some quick details and we can get back to you with a quick quote to help you make the right choice.




scotchegg logo