Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter banskt

    (@banskt)

    Thread Starter banskt

    (@banskt)

    Thanks for your reply. I really appreciate your help to get this thing sorted out.

    Now here are a few points to clarify the situation further:
    a)

    When we click on category, WP reloads page

    — No, to prevent reloading of pages (I want to make the browsing experience smoother), I load all category items at the beginning. All of them are shown by default. Javascript is used to hide them later, or re-show them.

    b)

    By clicking on category in one of this menus, WP queries posts and displays them trough category.php template

    — No, I use javascript to filter them. I know that I can filter them through WP_Query(‘cat=#’), but I preferred to use javascript to prevent reloading of pages.

    c)

    So i suppose that you use javascript not to filter posts, yet for an show/hide posts effect.

    I use javascript to filter posts. Filtering = hiding other posts

    That being said, I just realised that while filtering I can change the a href values using javascript and that will do the trick. Once I have the desired href value for the links I can parse that href value to get the category in PageTwo, since I will get the href value via $_SERVER['HTTP_REFERER']

    I will try that one and post it here.

    Many thanks,
    banskt

    Thread Starter banskt

    (@banskt)

    Hi,

    Thanks for the reply, and the heads up.

    Each post has more than one category.

    Now, $_SERVER[‘HTTP_REFERER’] will show the permalink of the post. Even if I change the permalink mode to /%category%/%postname% the permalink will show only one category, which might not be the one which is selected in PageOne.

    As far as I understand, this method can be used for subcategory navigation, provided one click on links with subcategory permalinks. (Note that I am clicking on permalink of a post, whose permalink reflects the last category, and NOT the selected category).

    I would be more than glad if I am wrong.

    The other solution – “get and store PageOne current category and then call it and use it on PageTwo” is the most obvious solution. But how could I implement it?

    The way I could think of was to set a javascript variable onclick(‘menu item’). Then the problems are:
    a) how could I send it to php?
    b) how could I send the variable to another page?

    I do not know any method of changing php variable on mouseclick. That could also be a solution.

    ————- Details about PageOne ————–

    Here I need to tell in more details about PageOne. I call all items of ParentCategory in a loop.

    <?php query_posts('cat=3&showposts='); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li class="<?php foreach((get_the_category()) as $category ) { echo $category->cat_name . ' all'; } ?>">
    <?php the_post_thumbnail('post-thumb'); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    Note that I have passed the subcategories as class of the

    • Now I use a menu :
      <ul>
      <li><a href="#cows" title="cows">cows</a></li>
      <li><a href="#dogs" title="dogs">dogs</a></li>
      <li><a href="#goats" title="goats">goats</a></li>
      </ul>

      Using the attr(‘href’) in javascript, I show or hide the list items of different categories (all, cows, dogs, goats), since I already have the <li class=”cows dogs all”>item1

    • in my html.

      ————– Details ends here —————–

      Thanks,
      banskt

Viewing 3 replies - 1 through 3 (of 3 total)