• Resolved geekgirl

    (@geekgirl)


    My site is located at lovelatoya.com
    and in my sidebar I tried to manually add the calender and custom titles I made. Here is a portion of my code (which is wrong because now my site won’t validate)…

    <h2 class="sidebartitle"><center><img src="images/cat.gif" alt="categories"/></center></h2>
    <ul class="list-cat">
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    <h2 class="sidebartitle"></h2>
    <?php get_calendar(); ?>
    <h2 class="sidebartitle"><center><img src="images/archive.gif" alt="archive"/></center></h2>
    <ul class="list-archives">

    <?php wp_get_archives('type=monthly'); ?>

    Although it looks right in my browser, the code is not correct and I’m not sure how to fix it. When I tried to validate my code it was telling me that I cant use the “center” tags there and that I placed the “li” wrong….Any suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter geekgirl

    (@geekgirl)

    Oh yea, the part of the above code that is in the bold print is the part that I edited.

    Hi
    Could you post the whole sidebar code please? It looks like your sidebar code goes something like this:

    <ul>
    <li>
    Some stuff
    </li>
    <li>
    Some more stuff
    </li>
    </ul>

    It ought to look more like this:

    Some stuff
    <ul>
    <li>
    Links etc
    </li>
    </ul>
    <h2>Header</h2>
    <ul>
    <li>
    Links etc
    </li>
    </ul>

    You’ll find it validates then. With the centre tag you need to place that in the css. So if you don’t want to centre (sorry I have to spell it like that I’m English) the whole sidebar use a class to centre that element. Something like this:

    .centrethis {
    text-align: center;
    }

    It gets a bit more complex with centring other elements. Post the code I’m sure we can help.
    Rich

    Thread Starter geekgirl

    (@geekgirl)

    Sorry about the previous post, I didn’t realize it recognized my code above as html, so I will try again to repost my sidebar code…But since last night I’ve managed to get rid of most of the errors I was getting when I tried to validate my code, but I still have 2 errors that I don’t know how to fix. Here is my sidebar code, any help is appeciated.

    <div id="sidebar">
    <ul>
    
      <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    
        <li>
          <?php include (TEMPLATEPATH . '/searchform.php'); ?>
        </li>
    
        <?php /* Menu for subpages of current page (copied from K2 theme) */
        global $notfound;
        if (is_page() and ($notfound != '1')) {
            $current_page = $post->ID;
            while($current_page) {
                $page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
                $current_page = $page_query->post_parent;
            }
            $parent_id = $page_query->ID;
            $parent_title = $page_query->post_title;
    
            // if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) {
            if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_type != 'attachment'")) {
        ?>
    
        <li>
          <h2 class="sidebartitle"><?php echo $parent_title; ?> <?php _e('Subpages'); ?></h2>
          <ul class="list-page">
            <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?>
          </ul>
        </li>
    
        <?php } } ?>
    
        <li>
          <h2 class="sidebartitle"><img src="images/cat.gif" alt="categories"/></h2>
          <ul class="list-cat">
            <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
          </ul>
        </li>
        <li>
          <h2 class="sidebartitle"><?php get_calendar(); ?></h2>
           <ul class="list-calender">
          </ul>
        </li>
        <li>
          <h2 class="sidebartitle"><img src="images/archive.gif" alt="archive"/></h2>
          <ul class="list-archives">
            <?php wp_get_archives('type=monthly'); ?>
          </ul>
        </li>
        <li>
          <h2 class="sidebartitle"><?php _e('Links'); ?></h2>
          <ul class="list-blogroll">
            <?php get_links('-1', '<li>', '</li>', '<br />', FALSE, 'id', FALSE, FALSE, -1, FALSE); ?>
          </ul>
        </li>
    
      <?php endif; ?>
    
     </ul>
    </div>

    <!–/sidebar –>

    Don’t post long code here: nobody can (and will) read it.
    Use https://wordpress.pastebin.ca

    as for “center” as an error: in XHTML has been deprecated, and most WP themes are XHTML.

    Thread Starter geekgirl

    (@geekgirl)

    Thank you for posting that link. (the only reason I posted my entire code was because the person who was trying to help last night asked me to). I removed my calender code which was this….

    <li>
          <h2 class="sidebartitle"><?php get_calendar(); ?></h2>
           <ul class="list-calender">
          </ul>

    and now my site validates again. Could you please tell me the correct calender code? Also should I start a new post since all those codes are in the way?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘help with sidebar code please’ is closed to new replies.