• sannevanschie

    (@sannevanschie)


    Hi, i need to put the current category id in a parameter, does anyone know how to do this?

    my code is like this:
    `<?php if (is_category()) { //check if current page is a category
    $args = array( ‘numberposts’ => 9, ‘category’ => ‘31,3,11,4,32,29,30,27,28,26,-$cur_cat_id‘, ‘posts_per_page’ => 9,’paged’ => $paged);
    }

    Hope someone knows

Viewing 6 replies - 1 through 6 (of 6 total)
  • graphical_force

    (@graphical_force)

    So are you executing this code when someone clicks on a category and not a single post?

    Thread Starter sannevanschie

    (@sannevanschie)

    yes, i acctually have two columns (loops) with posts, the left one displays of instance posts with category id’s 1, 2, 3, the right displays 4, 5 and 6

    but when someone clicks on a category, they are displayed in the left column (loop) so i then want to prevent them from displaying in the right also.

    graphical_force

    (@graphical_force)

    I’m confused. You say ‘when they click on a category, they are displayed in the left column’ – what are you talking about? Posts from that category? Do you have a link that you can share that shows what you are doing?

    Thread Starter sannevanschie

    (@sannevanschie)

    I can’t because it’s a password protected site at the moment.

    I mean if someone wants to see al the posts for instance from category 6 ,these posts are normaly displayed in the right column but now the category displays them aswell in the left column and i don’t want that.

    like this:

    left – right
    1,2,3 – 4,5,6

    someone clicks 6 and it’s like this:
    6 – 4,5,6

    but i want:
    6 – 4,5 (and not 6)

    I hope this is understandable, sorry i can’t send a link…

    graphical_force

    (@graphical_force)

    What about using is_category https://codex.www.ads-software.com/Function_Reference/is_category

    and they do something like:

    if (is_category( 'catName or id' )){
     $cur_cat_id = id of that Category;
    }

    and so forth so $cur_cat_id gets the id of each category id by using conditional statements.

    Thread Starter sannevanschie

    (@sannevanschie)

    Yes, I solved it like this:

    before the loop I check the current category

    <?php $category = get_the_category(); ?>

    Then in the loop I check if it’s a category page, if so, if the post is the same category as the current one i continue

    <?php if (is_category()) {
    if (in_category( $category[0]->cat_name )) { continue; }} ?>

    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘variable in parameter’ is closed to new replies.