Jump to content

How to parse url for search query


thomasfals

Recommended Posts

The build up:

 

I am a wordpress / php newbie so bare with me - I use the following to change classes on a menu element according to the category (this is one of many buttons)

 

<a href="/category/presets/photoshop_actions" title="Only Photosshop Actions"
        <?php if (is_category(photoshop_actions) || is_single() && in_category('47')) {
            echo ' class="rounded rounded_active" ';}
            else{
            echo ' class="rounded" ';}  
        ?>
        >
        <span>
            Photoshop Actions
        </span>
</a>

 

As you can see I get the class rounded_active added if the category is 47. So far so good.

 

The question:

 

When I perform a search within this category I also want the class to be set to rounded_active. For this I guess I will have to parse the url that looks like this:

http://localhost:8888/?cat=47&s=boats 

 

So how do I parse the url and store the cat id in a variable? That way I could use it in the if statement.

 

Any help will be very welcome indeed :D

 

 

Link to comment
https://forums.phpfreaks.com/topic/207874-how-to-parse-url-for-search-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.