Some users of of arthemia theme would like to display pages instead of categories in the category bar of this theme.
This bar has a custom styling for each of the 5 categories displayed.
What we are going to do is take off the list of categories and replace this list with a list of pages.
The bar is created in index.php of arthemia theme and I refer to this file with the given styling.
From line 52 to line 70 (if unmodified) you find:
<div id="middle" class="clearfloat">
<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" />
--------------
All stuff in here we are replacing by the code given below!!
The image category.png you can change to what you like or remove this whole line too
--------------
</div>
<?php } ?>
<div id="bottom" class="clearfloat">
Let’s come to the replacement:
We insert this:
<?php
$pages = get_pages(); $i = 1;
foreach ($pages as $page) { ?>
<div id="cat-<?php echo $i; ?>" class="category">
<span class="cat_title"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></span>
</div>
<?php $i++; } ?>
to call all pages and give them the style of the categories we had before.
Now it could be you have more than 5 pages or you do not want to display some of them. I suggest using the ‘include’ parameter and include exactly 5 of your pages.
The second line of this code could look like this:
$pages = get_pages('include=2,41,42,132,134'); $i = 1;
here I included the pages with IDs of 2 and 41 etc, just five of them to fit in
To list subpages or even excerpt of that pages – there is sure a way…
Update to get a description like there is a description for categories in this theme:
To get a description for each page we show in the category bar of arthemia we use a custom field as you have to use for images in posts.
Edit your pages where you want to get a short description and scroll in page editor down to ‘Custom Fields’
In “Add a new custom field:” under Key you enter ‘ pagedesc ‘ (just eight letters, no hyphen) and under Value any text you like to have as description for that page.
To be able to see this description you have to insert an updated code, actually same as above but with a query for this new created field and a command to echo it if it is there:
Full updated code here:
<?php
$pages = get_pages('include=2,41,42,132,134'); $i = 1;
foreach ($pages as $page) { ?>
<div id="cat-<?php echo $i; ?>" class="category">
<span class="cat_title"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></span>
<?php if(get_post_meta($page->ID, "pagedesc", true)){ ?>
<a href="<?php echo get_page_link($page->ID) ?>"><?php $key="pagedesc"; echo get_post_meta($page->ID, $key, true); ?></a>
<?php } ?>
</div>
<?php $i++; } ?>
happy coding, give a comment if it is not working…
Another update: Sort the page entries as you like:
insert in this line:
$pages = get_pages('include=2,41,42,132,134'); $i = 1;
the parameter &sort_column=menu_order like this:
$pages = get_pages('include=2,41,42,132,134&sort_column=menu_order'); $i = 1;
then adjust in edit page on the right side under ‘order’ to give a value like first page in that row give 2, second one 4 third the 6,
it’s just like playing games as you have to try.