Please Check This 20 Lines Of PHP Code

4 replies
Ok, This one really had me pulling my hair,

Here's the code
---------------------------------------------------------------------
<?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&depth=1&show_count= 0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
}

else{
<ul>
<?php
$post;
$myposts = get_posts('category=$this_category->cat_ID&numberposts=1000&order=asc');
foreach ($myposts as $post) : setup_postdata($post);
?>
<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
}
?>
--------------------------------------------------------------------------
It's just 20 Lines and I checked at several online Checkers which say that there's a parse error in the ELSE LOOP

I can 't seem to figure out what may that be?

Can anybody help??

Thanks in advance
Bhupinder
#authenticate code #check #code #lines #php #php lines #software code
  • Profile picture of the author SteveJohnson
    PHP Code:
    else{
    <ul>
    <?php 
    ;
    You're missing a closing ?> before the '<ul>' tag
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[1952785].message }}
  • Profile picture of the author wayfarer
    </ul>
    }
    ?>
    at the end, should be:
    PHP Code:
    </ul>
    <?php
    ?>
    There needs to be an opening <?php tag for the end of your ELSE construct.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[1952795].message }}
  • Profile picture of the author Mohsin Rasool
    Yeah it should be:

    PHP Code:

    <?php if (is_category()) {
     = 
    get_category();
    if (
    get_category_children() != "") {
    echo 
    "<ul>";
    wp_list_categories('orderby=id&depth=1&show_count= 0&title_li=
    &use_desc_for_title=1&child_of='
    .);
    echo 
    "</ul>";
    }
    }

    else{ 
    ?>

    <ul>
    <?php
    ;
     = 
    get_posts('category=&numberposts=1000&order=asc');
    foreach ( as ) : 
    setup_postdata();
    ?>
    <li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    <?php }
    ?>
    {{ DiscussionBoard.errors[1952876].message }}
  • Profile picture of the author howudoin
    Thanks Guys, It's working now!
    {{ DiscussionBoard.errors[1953046].message }}

Trending Topics