5 Quick WordPress Tips!

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 sub-menu 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.