Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. Hi Joern - me again! I know I've seen this elsewhere but I can't find it - have you got the code tweak for changing the category belt so that one of the 5 links goes to a static page? It's driving me bonkers!

    Posted 1 year ago #
  2. you want 4 links going to a category and one to a page?
    If the page is the first or the last in this row, it will be easier, otherwise being displayed somewhere between mor difficult, what do you want?
    I need 4 category IDs and one page ID (or title)

    Posted 1 year ago #
  3. Howdy - the page could be linked as either the first or the last, I'm happy either way.

    Cat nos:
    9,10,11,12

    Single page 'win' (www.iamstaggered.com/win)

    Posted 1 year ago #
  4. okay, I will put it at the end of the row.

    you have to modify this part in index.php, should still look similar like this now:

    <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(9,10,11,12,xx); $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>

    I will remove one category in that row, so there is only 4four left, 9,10,11,12
    this $i = 1 counts only how often you run the query to put out div id="cat-<?php echo $i; ?>", reads div id="cat-1" to cat-4 now
    finally just put a new query for one page (win) just below, having the div id="cat-5",
    querying for 'win', bring the title and the excerpt in the respective span classes
    The except might be too long, you should use a custom excerpt with the length you like.
    here the new code to replace exactly the stuff above:

    <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(9,10,11,12); $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 id="cat-5" class="category">
    		<?php query_posts('pagename=win'); //retrieves the win page only ?>
    		<span class="cat_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"></span>
    		<a href="<?php the_permalink() ?>"><?php the_excerpt(); ?></a>
    	</div>
    
    </div>

    Did not try it, hope no typing error, but should work..
    good luck an BACKUP!! first

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):