• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

filtering posts from menu



Ok guys n gals :) I need to be able to filter posts from Wordpress when clicking on a menu button (the menu items are today, this week, this month, last month) I need a code to filter the posts so that if you click on today it will show all the posts from today, if you click on this month it will show all the posts from this month etc etc.. anyone know how to get this to work?

Thanks in advance everyone :D


Active Member
I've been doing a lot of wordpress recently but not sure on this one... might be worth posting on the stack overflow website?


Ta Andy... Wordpress is a great program... but i've found a few things like this to be just beyond their basic coding.. it goes into Advanced PHP and Wordpress coding LOL :)


Well basically Jaz me old mate :) I have a menu across the top of my site and I want it to sort the posts (which have all be tagged under Misc in Wordpress) into the following: Today, This Week, Last Week and Last Month. They are all menu items in a left to right in line set...

If you look at http://www.newsswipe.co.uk and you will see the list of Today etc across the top in the header.. those are the links I want to make work with the filtering :)

I hope that makes some sense :D


Active Member
Okay could you give me a run down of how wordpress works?
Don't use it TBH, do you have access to the DB if so what kind of DB is it?

You may be able to but if JS is disabled or the search engines want to visits it, which I'm sure Chris would want, then it's going to lead to problems. :)


How do you want the rundown Jaz? :) The DB is a phpMySQL DB if that helps?

On a separate question I am also needing to make a different site (for work) change language.. I'm using a plugin to change the language dynamically :) but what I need it to do is change the CSS files when they change the language as the languages i'm changing it into have some longer and shorter words.. so I need to accommodate the differences. Any ideas how i can achieve this too?


Active Member
Dynamic links
Well the DB I can help with as I know MySQL..
Can you access it directly thats the only thing in the way now?

If you can access the DB and can view the table names, don't post what they are called if you can, let me know and then I can write you some PHP code to query the DB and fetch the data, should work don't use Wordpress so not sure but hay we can give it a go. :)

You would also need to know the DB password and username again don't post them. :D

Separate language
How I would set it up is separate them into sub directories, preferably sub domains as sub domains are treated by the search engines as a separate site then just link to the sub folder with the other language in, then in there add a separate CSS sheet that way you get a separate language of your site indexed and thus hopefully in other language search results however that is not that easy or as simple as that, foreign language SEO is harder to pull off. Ideally you want each language to have it's own server placed in the languages main home country or where most of your visitors will come from in that language as well, as well as links with the right keywords in the other language pointing to the right language version of your site.

If however you just want to offer it to your site visitors set a link to the language then test for the variable and add a new CSS sheet, similar to how I do my zoom css sheet in the accessibility thread.

So we have XHTML similar to:
Please chose your language below:
<li><a href="this-page.htm">English</a></li>
<li><a href="this-page.htm?lang=francais">French</a></li>
<li><a href="this-page.htm?lang=deutsch">German</a></li>
<li><a href="this-page.htm?lang=italiano">Italian</a></li>

Then at the top of the page ~
<link href="css/main.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/page2.css" rel="stylesheet" type="text/css" media="screen" />

<?php if(isset($_GET['lang']){
if($_GET['lang'] =="francais" || $_GET['lang'] =="deutsch"){?>

<link href="css/french-and-german-fix.css" rel="stylesheet" type="text/css" media="screen" />
<?php }elseif($_GET['lang']=="italiano"){?>
<link href="css/italian-fix.css" rel="stylesheet" type="text/css" media="screen" />
<?php }}?>

Then personally I would add this to the end of all your links.

<a href="some-page-url<?php if(isset($_GET['lang])){?>?lang=<?php echo $_GET['lang]; }?>">some page</a>

That way the get variable is added to the end of every link and if some one then clicks on the French version all the pages off it will then display the French version when they follow a link from that page as the get variable will be present if that makes sense.

If the user chooses via a form that bottom section will need to be changed and the top section will need to be changed to a post rather than a get let me know if that is how it is implemented or if you would like me to amend it for a form submission.

Red ~ PHP
Blue ~ XHTML


Active Member
no worries. :)
im assuming your pages are just plain html, is this correct?

if so u need to create a .htaccess and place it on your root directory, if u havent already, n write this in it -

AddHandler application/x-httpd-php .php .html

as that will tell all your html pages to be parsed as php pages. php doesnt require php to actually be on the page so you dont have to worry about pages that will have no php in them spitting out an error. for the above to work if they are html pages.