go41

combination of categories AND pages in arthemia category bar

von Joern am 14. Apr. 2011 | Keine Kommentare

The question is:

I would like to have a combination of categories AND pages in my category bar. How would I do that?

Preferbly 4 categories and 1 page (at the end of the bar).
Help would be so much appreciated!!
Answer:

I would do it by adding this one page into the code of index.php
Normally the category bar code looks like this:

<div id="middle" class="clearfloat">
<img src="<?php echo get_option(‚home‘); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" />
<?php $display_categories = array(5,6,7,8,11); $i = 1;
foreach ($display_categories as $category) { ?>

<div id="cat-<?php echo $i; ?>" class="category">
<?php query_posts("showposts=1&cat=$category")?>
<span class="cat_title"><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></span>
<a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a>
</div>

<?php $i++; ?>
<?php } ?>

</div>
Now we are going to let this query above show only 4 categories plus one page at the end.

we change $display_categories = array(5,6,7,8,11); to $display_categories = array(5,6,7,8); by removing any one category ID so there are only 4 left.

The fifth entry we ‚hardcode‘ into this part by adding some lines for div id="cat-5"
the complete code will look like this, please set your own page details

<div id="middle" class="clearfloat">
<img src="<?php echo get_option(‚home‘); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" />
<?php $display_categories = array(5,6,7,8); $i = 1;
foreach ($display_categories as $category) { ?>

<div id="cat-<?php echo $i; ?>" class="category">
<?php query_posts("showposts=1&cat=$category")?>
<span class="cat_title"><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></span>
<a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a>
</div>

<?php $i++; ?>
<?php } ?>

<!– page start –>
<div id="cat-5" class="category">
<span class="cat_title"><a href="link to your page">Title of your page</a></span>
<a href="link to your page">Description of your page as you like</a>
</div>
<!– page end –>

</div>
For Annemieke who asked this question in my blog, the new part will look different!!

Annemieke take of one ID from the query and add this pls:

(put your link, title and description in there!)

<!– page start –>
<div id="cat-5" class="category" onclick="window.location.href=’http://yoursite.xxx/yourpage/’" >
<span class="cat_title">TITLE OF YOUR PAGE</span>

<p>Description op het gebied van eten & drinken en stijlvolle hotspots – just kidding!</p>

</div>
<!– page end –>
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Sorry, no posts matched your criteria.

Autor:

Du findest mich auch auf Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

weitere forum Beiträge: