I am currently developing a theme for a client but I am stuck with something I never encountered before.
The mechanic of the website is that you will get different category articles displayed as a function of 2 things : the “year” you have selected and the current page. I have used global functions (storing it in the URL) in order to retrieve the year and I am simply defining in each custom page the current page with a function. At the top of each of my custom page I have therefore defined :
<?php $pagecourante="accueil"; $_GET['fonc']; $fonciere=$_GET['fonc']; ?>
$fonciere is the year (from 2013 to 2018) and $pagecourante is the french for currentpage.
In order to select the category I want for each page, I have made a php table that looks like that (put in function.php), first  is the year and the second one is the current page. The number at the end is the category id. It just means that if you have selected $fonciere=2013 and $pagecourante=accueil, then I want $conv to return 10, wich is the category of articles I want to display under such circumstances.
$conv[accueil]=10; $conv[compta]=11; $conv[juridique]=3; $conv[lots]=5; $conv[tdb]=4; // - $conv[accueil]=12; $conv[compta]=13; $conv[juridique]=9; $conv[lots]=14; $conv[tdb]=5; // - $conv[accueil]=17; $conv[compta]=18; $conv[juridique]=19; $conv[lots]=20; $conv[tdb]=21; // - $conv[accueil]=23; $conv[compta]=24; $conv[juridique]=25; $conv[lots]=26; $conv[tdb]=27; ?>
Now, I would like to be able to do get the loop displayed and define each category by simply putting
'cat=$conv[$fonciere][$currentpage]'wich would return 10 if you are in year 2013 and the current page is accueil for instance.
However, this is not working, I can’t seem to be able to call a category with a function, that’s why I am looking for your help dear fellas. Is it my syntax that is wrong or the whole reasoning?
I thank you in advance for your help
- The topic ‘'cat=$function' in order to get posts from a category (loop)’ is closed to new replies.