Maximising your online presence with bespoke design and development

websites, online stores, content management systems, online applications, social profiles and more ... call now - 020 7193 6109

WordPress as a CMS – Part 2

In the previous installment we talked about minor tweaks to the underlining code that enabled you to use WordPress as a CMS.


In WordPress as a CMS – Part 2 we will look at content display structure – defining what info is needed and how it’s built – what will regularly change (news, events) and what content is static, (about us, contact us).


Pages or posts?
Pages
Essentially any static info can be created as a page. Assuming your navigation is set up correctly, creating a new page will be added automatically to your navbar.


Using this code will create a basic, auto-updating, navigation list:
<ul class=”pages”>
<li<?php if( is_home() ) : ?> class=”current_page_item”<?php endif; ?>><a href=”<?php bloginfo( ‘url’ ); ?>” title=”<?php bloginfo( ‘title’ ); ?>”>Home</a></li>
<?php wp_list_pages( ‘title_li=&depth=1&exclude=25,35′ ); ?>
</ul>


Huh? -
<?php if( is_home() ) : ?> – If this page is home do something – In this case add the “current_page_item” class.
<?php wp_list_pages( ‘title_li=&depth=1&exclude=25,35′ ); ?> – List the pages, with their title but exclude pages 25 and 35.


Posts
Any info that changes regularly is best suited to being a post. Using custom code, technically you can place this content anywhere.


This code can be used, for example on the front page, to display the post excerpt with thumbnail:


<div class=”minipost”>
<?php
$minicat2 = get_option(’remedy_mini_category2′);
$my_query = new WP_Query(’category_name=minipost2&showposts=1′);
while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
?>
<div class=”hentry”>
<?php $homethumb = get_post_meta($post->ID,’homethumb’, true); ?>
<a href=”<?php the_permalink() ?>” title=”<?php the_title(); ?>”><img src=”<?php bloginfo(’url’); ?>/images/<? echo strtolower($homethumb); ?>.jpg” width=”100″ height=”60″ alt=”<?php the_title(); ?>” title=”<?php the_title(); ?>” /></a>
<h2><a href=”<?php the_permalink() ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div>
<div class=”meta”>
<div class=”postmore”><a href=”<?php the_permalink() ?>”>Read more on <?php the_title(); ?></a></div>
</div>
<?php endwhile; ?>
</div>


Huh? -
$my_query = new WP_Query(’category_name=minipost2&showposts=1′); – Display the latest post in category ‘minipost’.
/images/<? echo strtolower($homethumb); ?>.jpg” – Get the name and display the file named in the ‘homethumb’ custom field.
<?php the_excerpt(); ?> – Post the excerpt content.


Disable comments
One thing that differentiates a blog to a website is the ability to comment on posts. As we are using WordPress as a CMS (therefore as a website) you might want to disable comments.
If so, go to ‘Discussion Settings > Default article’ and then make sure ‘Allow people to post comments on new articles’ is unchecked.
If you choose to, you can also edit your single.php or page.php files, if required, and delete the code that calls the comments.php file.


That’s all for now. Follow Point and Stare on Twitter or just come back soon for another installment.


Slashdot Digg del.icio.us Share on Facebook Add to my Technorati Favorites Save to Google Bookmarks Stumble it!
fix for IEFollow Point and Stare on TwitterBecome a fan of Point and Stare on FacebookSubscribe to the Point and Stare RSS feed