Support » Fixing WordPress » Trying to append a value to permalink…

  • The WP Page is called Teams, and I have a table of data from my database. I want my Users to be able to sort via each column, but I don’t think the ‘sortby’ values are being passed when the User clicks on the column header.

    <table width="100%" class="first_impressions">
            <td width="21%"><b><a href="/teams?sortby=coachLast">Name</a></b></td>
            <td width="23%"><b><a href="/teams/?sortby=school">High School</a></b></td>
            <td width="13%"><b><a href="/teams/?sortby=sectional">Sectional</a></b></td>
            <td width="8%"><b><a href="/teams/?sortby=class">Class</a></b></td>
            <td width="35%"><b><a href="/teams/?sortby=email">Email</a></b></td>
    if (!isset($_GET['sortby'])) {
    $sortby = "sectional";
    $query = 'SELECT * FROM hhr_schools ORDER BY '. $sortby .' ASC';
    else {
    $sortby = $_GET['sortby'];
    $query = 'SELECT * FROM hhr_schools ORDER BY '. $sortby .' ASC, nameLast ASC';
Viewing 12 replies - 1 through 12 (of 12 total)
  • I am not using pretty permalinks, so I had to use a page_id in the links, and my site name is ‘test’, so the links look like this:

    <td width="21%"><b><a href="/test/?page_id=206&sortby=coachLast">Name</a></b></td>

    but that works for me.

    That’s not working. Is there a certain way I should have my permalinks set up for Pages?

    Can you post a link to your site so I can see the generated html?

    Did you use your own site name and page_id?

    I have tried this with both the default and ‘pretty’ permalinks. It works both ways. But, I am testing on a local install, so it may be different on a remote host. You may need to use the whole url rather than just the relative one.

    I haven’t checked the code in the browser yet. 🙁
    I’ll do that when I get back.

    The links seem to be pointing to the correct page, with the correct ‘sortby’ arg.

    But, I noticed that in the code snippet you posted that you used ‘nameLast’ in the ORDER BY clause, but when I hover over ‘Name’ in the page, I see ‘coachLast’. Is ‘nameLast’ really a column in the table? If not, your order by is probably being ignored.

    Have you tried printing out a message showing the sortby arg?

    echo "<h2>SORTBY:{$_GET['sortby']}</h2>";
    if (!isset($_GET['sortby'])) {
    $sortby = "sectional";

    Yes, the code snippet was corrected since posting that code.

    I just printed the sortby arg, but it’s blank. It’s not passing the code.

    It may be theme related. I saw a similar problem where the arg ‘year’ was not passed because it was ‘registered’ with WP (also with ‘paged’). Try changing the arg to mysortby or something else really unique.

    I changed it. It’s still not passing the variable. 🙁

    Last thing I can think of – switch to the default theme and see if it works there.

    It still didn’t work.

    I even changed to the Default permalink setting. It’s just not passing the appended variable. I’m wondering if being a Page vs. a Post changes how that works.

    I tested it on a Page that I use for testing code snippets and it worked there. Maybe some plugin is filtering the query.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Trying to append a value to permalink…’ is closed to new replies.