• Resolved dekraan

    (@dekraan)


    Please check out: this link and click on ‘about’ or ‘blog’. Please do not mind the lay-out, I am tinkering with it, and will ofcourse add my own colors and touches!

    When you go to about, in the sidebar you first see the parent page and subpages, if there are any. I used the code

    <ul><?php
      if($post->post_parent){
        $parent=get_post($post->post_parent);
        $children = '<li><a href="'.get_permalink($post->post_parent).'">'.$parent->post_title.'</a></li>';
        $children .= wp_list_pages("title_li=&amp;child_of=".$post->post_parent."&amp;echo=0");
      }else{
        $children = '<li><a href="'.get_permalink($post).'">'.$post->post_title.'</a></li>';
        $children .= wp_list_pages("title_li=&amp;child_of=".$post->ID."&amp;echo=0");
      }
    echo $children; ?>
    </ul>

    When you look lower, you see some other things as well: categories and archives.

    The code here is:

    <h2>Categories</h2>
    
    			<ul>
    				<?php wp_list_cats('sort_column=name&amp;optioncount=0'); ?>
    
    			</ul>
    
    		</div>
    
    		<div style="margin-bottom:10px;">
    
    			<h2>Archives</h2>
    
    			<ul>
    
    				<?php get_archives(); ?>
    
    			</ul>
    
    		</div>

    What I want, is to have the archives and categories only appear on my parent page called blog. How do I do this? On the other pages, it shouldn’t appear! I hope anyone knows

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php if(is_home()) { ?>
    stuff for your sdebar here
    <?php } ?>
    Thread Starter dekraan

    (@dekraan)

    Do you mean, I should put the second, or the first bit between these tags? And: since I want the second stuff to apear on a page I called ‘Blog’, should it be:

    <?php if(is_Blog()) { ?>
    stuff for your sdebar here
    <?php } ?>

    or wouldn’t that work? Thank you for your reply!

    no – there’s no such conditional as “is_blog()”. “is_home()” refers to the index page of your blog.

    If you have a static Page set as the front page of your site, then you need to use “is_front_page()”

    You don’t have the entire sidebar posted here, so I don’t know exactly where you want to put it, but basically it should be set up like so:

    <div id="sidebar">
    <?php if(is_front_page()) { // or is_home, if you don't have a static front page set ?>
    put in what you want to show on the index page
    <?php } else { ?>
    put in what you want to show on the rest fo the site
    <?php } ?>
    Thread Starter dekraan

    (@dekraan)

    I understand, but is it also possible to exclude pages? I have an index page, but also an about-page etc. They are not blogs, so: the only page I want to say if(is_….) about, would be my blog-page, which is actually a category, if I am not mistaken.

    EDIT:
    hello! I used

    <?php if(is_page()) { ?>
    <?php } ?>

    for the first part, so that the parent_page and children only appear on a page, and used:

    <?php if(is_category()) { ?>
    <?php } ?>

    for the two second things (the archive and the categories). And it works! Thank you for your help ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Discluding pages from sidebar – categories’ is closed to new replies.