0

This is the situation:

I made a portfolio page for photographies. The gallery is already on the front page, so the first thing the visitor sees when calling www.homepage.com (example)

This loads all the images into the gallery, despite their category. Each image does have one or more categories assigned (one of which is 'all', which all pictures have, obviously).

The filter works as following: the navigation buttons for choosing a category are actually submit-buttons, that print the according category name into the URI, like so

www.homepage.com/?all=

The PHP reloads the page and puts this '/?all=' into a variable, strips it of all special characters and leaves 'all', which then filters the images as wanted and shows only those.

I hope it makes sense so far.

The problem is, that I want the first thing for the visitor to see be this:

www.homepage.com/?all

so he only does see all the images with that category assigned to it (I mentioned that all images have that, but that's not entirely true, my client wishes to exclude certain categories that are less important, but can be found by choosing this particular category in the menu. Achieved by simply not assigning the category 'all' to them)

So far I tried to change the standard URI of the page to this link via my hosting settings, which didn't work (too many redirects error).

I also tried a wordpress function to redirect the page with the added info

<?php wp_redirect( home_url( '/?all' ) ); exit; ?>

but again, the redirect-error strikes. And since I didn't use wordpress in quite a while I'm already at my wits' end.

Is there any way to solve this elegantly, without reprogramming the whole filter system?

Thanks in advance :)

-edit- I might want to add, that this should only be done the first time someone visits this particular page (so it doesn't negate the filtering process upon reloading this very page) and it obviously shouldn't affect any other page ( About, Contact etc.)

Romeryo
  • 1
  • 1
  • I don't know much about ModRewrite but this might help - others might suggest ideas or you could edit the question to request info http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained – Steve Dec 13 '15 at 06:00

1 Answers1

0

I solved this in another way (which was actually dead simple...)

Before I fired the WP function that put all the relevant post-data into the $args array I added an if-statement right in front of it that checked whether the $category Variable was empty or not. If so (and this is the case when the function prior to that cannot pick data from the URL) it will assign the variable "all" to it by default.

The Code then looks like this:

if(!$cat){
  $cat = 'all';}

and that's basically it.

Romeryo
  • 1
  • 1