Forum Replies Created

Viewing 15 replies - 1 through 15 (of 153 total)
  • Try to remove "position: absolute;" from .narrowcolumn. Its totally unnecessary and probably messing up your whole design.

    But where do you think your sidebar is? I don’t see one ;-).

    How exactly do you get the list of categories in the menu? Do you use widgets?

    By all means, post a link! ??

    But I suspect, that what you want to accomplish could be complicated without a java-menu. What exactly do you mean by “when I click on a category, the subcategories should appear”? Appear in the menu?

    What’s the difference between “internal” and “external” links? Of course, you won’t get any nice permalinks like /my-page/ if you don’t publish them, but the others should work.

    It works for me. The only “problem” I can think of is, that it probably just works for logged in admins, but that you have to try yourself :).

    Forum: Fixing WordPress
    In reply to: Create a query

    Modify query_posts('cat=4'); to query_posts('cat=4&showposts=4');. See query_posts() in the codex for more options.

    Hmm, you could write a page and save it, but not publish it. This way, you could access it with /?page_id=xx, but it won’t show up in the pages list.

    So far, so good. Be sure to include the first p-tag, which contains your header image and that bold piece of text, in <body> and the #wrapper-div, but before the #container-div starts.

    Now look for this in your style.css:

    div#wrapper {
    	margin: 3em 0 0 0;
    }

    and replace it with:

    div#wrapper {
    	width: 80%;
    	margin: 3em auto 0 auto;
    }

    We really need more information on what exactly you want to change… where do you want the remaining 20% (left or right?). Do you want content in there?

    But before we start making suggestions, you should correct one serious mistake: <body> includes <head> (not allowed). Furthermore, your divs are #container -> #wrapper -> #container -> #content. At least the first #container is unnecessary, maybe the second one as well. There are also lots of minor structural errors (with lists, headlines, etc). This will help you to eliminate them.

    By the way… this has nothing to do with php, it’s only a css issue, so don’t worry about limited php knowledge ;).

    Just replace your line <?php the_excerpt() ?> or <?php the_content() ?>(whatever it is in your theme) in the loop with the line I provided. “i” is being defined at the end of that line. The only premise is, that you don’t use a variable $i somewhere else, but that’s usually not the case.

    How about this in the Loop, where it probably says <?php the_excerpt() ?> now:

    <?php if (!i) the_content(); else the_excerpt(); i=1; ?>

    Assuming you don’t use “i” as a variable otherwise, it will be set after the first post (whole content) is displayed, and remains set, when that if-statement checks for the second post and more. Just an idea, I haven’t tested it.

    Maybe you have better luck with wp_list_categories, because list_cats is deprecated as you can see here.

    Hmm, my guess is, that category_parent isn’t part of the query if one calls a single post… try this one, but I haven’t tested it:

    function get_parent_category() {
     foreach ((get_the_category()) as $cat) {
     if ($cat->category_parent) return $cat->category_parent; }
    }

    Eventually, this won’t work as expected if a post is in more than one child category. In that case, I think it will return the parent category from the highest child category ID. If the post is in one child category AND one “normal” category, the function should return the child’s parent category ID. If the post is in no child category, the function shouldn’t return anything.

    You can leave the code in your single.php as it is now.

    Hmm, i think, there was an error in my logic, because the function will always return an ID, so the code in single.php will always call this_template. Maybe you need the function modified that it only returns a value, if a category has a parent. The rest will be in single.php. Try this one:

    function get_parent_category() {
     global $wp_query;
     $category = $wp_query->get_queried_object();
     if ($category->category_parent) return $category->category_parent;
    }

    and in your single.php…

    <?php $id = get_parent_category();
     if ($id == 10) {
     include(TEMPLATEPATH . '/this_template.php');
     } elseif ($id == 11) {
     include(TEMPLATEPATH . '/that_template.php'); // and so on
    } else {
     include(TEMPLATEPATH . '/a_different_template.php');
     } ?>

    An even nicer way would be to name the templates "template10.php", "template11.php" and so on, and integrate the value of $id directly, or use a_different_template if there is no parent category:

    <?php $id = get_parent_category();
     if ($id) {
     include(TEMPLATEPATH . '/template' . $id . '.php');
    } else {
     include(TEMPLATEPATH . '/a_different_template.php');
     } ?>

    Of course, you’d have to amend the parent category IDs in the filenames (template10.php, template11.php, etc) to your needs. Good luck! ??

    I guess, it depends on if you like to have the number in the link or not. But your idea is certainly worth 1/10 of that reward :D.

    I wrote a small function for another reason, but maybe it works for you as well. Add that to your functions.php:

    function get_parent_category() {
     global $wp_query;
     $category = $wp_query->get_queried_object();
     if ($category->category_parent) return $category->category_parent;
     else return $category->cat_ID;
    }

    If a category has a parent, it returns the parent ID, if not, just the ID. In your single.php, you’d have to assign that to another variable and use it with in_category:

    <?php $id = get_parent_category();
     if ( in_category('$id') ) {
     include(TEMPLATEPATH . '/this_template.php');
     } else {
     include(TEMPLATEPATH . '/a_different_template.php');
     } ?>
Viewing 15 replies - 1 through 15 (of 153 total)