• Hi!

    Before I started using Permalinks i used code like if($_REQUEST[‘cat’]) to add special code for my pages where the category-postings are displayed …

    Now I cannot do this anymore since there is no more “request”-variable. My URL is now https://www.x.com/category/name/

    Any ideas how to do what I did before but with permalink on?

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • How about using is_category() that tells you if you are in the category archives — that is, it is true if you are in the category archives…
    Those are called Conditional Tags, and you can do all kinds of great things with them! ??

    Thread Starter Tobias Jordans

    (@tobias)

    Thats great.
    I hoped sb would point me to somthing like this ??

    Thanks a lot!

    Thread Starter Tobias Jordans

    (@tobias)

    But: If I use my _request-version I have another possibility: I can read the cat ID and page ID that is written in the URL
    I cannot do this with permalinks and it seems to be impossible as well with the conditional tags.

    Suggestions?

    You can get the category number with some code (it’s been discussed just recently) if you need it outside the loop (I guess inside the loop, there’s template tag for it). With is_category you can specify which category the condition is true for, e.g. is_category('8'); or the same with page, is_page('about-me')

    Thread Starter Tobias Jordans

    (@tobias)

    Thx for reply, Minna.

    The problem: is_category just returns true, not the cat-number.
    What I want do do is to echo the description and name of the cat above my posting.

    So with this technik i would have to write a condition for each cut —- mh…. wait — there is another way — i will test it ??

    I do this:
    if ( is_category() ) {
    <h1><?php single_cat_title('',true); ?></h1>
    <?php echo category_description(); ?>
    }

    to show the category name and description in the archives

    Thread Starter Tobias Jordans

    (@tobias)

    OK, this way it works:

    for ($i = 1; $i <= 60; $i++) {
    if (is_category($i)) {
    echo “…”.get_catname($i).”… “;
    if (category_description($i))
    echo “…”.category_description($i).”…”;
    echo “
    “;
    }
    }

    Would be perfect to find a .countCategory() to replace the value 60 but is fine so.

    Thread Starter Tobias Jordans

    (@tobias)

    @your code:

    before working with permalinks i could write stuff like
    cat=1+33+20
    that would show the postings belonging to all of them.

    That is why I use this more complicated way.

    Unfortunatelly right now I am not shure if I can do this nested cat-call anymore but I am testing…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘if($_REQUEST[‘cat’]) with permalinks on’ is closed to new replies.