1

I am using wp 4.94 for web library. In the categories sections I give the option to the users to order the posts in three different ways, by date, by title and by author, ascending and descending. However, only sort by date works. This is implemented through links

echo '<p align="center">Ordenar por titulo: &nbsp;</p>';
                echo '<p align="center">';
                echo '<a href="' . get_option('home') . '/?cat=' . $category->cat_ID . '/?orderby=title&order=asc"><b>Ascendente</b></a>';
                echo '&nbsp;/&nbsp;';
                echo '<a href="' . get_option('home') . '/?cat=' . $category->cat_ID . '/?orderby=title&order=desc"><b>Descendente</b></a>';
echo '</p>';

The link is like this.

http://localhost/blog/?cat=25/?orderby=title&order=asc

Sort by title alphabetically and by author, do not work. why? it's a clean installation, no plugins or anything installed

  • 1
    how do you set the $category variable? you might have the wrong syntax in your code; compare with: echo '<a href="' . get_option('home') . '/?cat=' . $category->cat_ID . '&orderby=title&order=asc"><b>Ascendente</b></a>'; – Michael Apr 1 '18 at 19:49
  • through if (is_category() { echo... } – Texas Apr 1 '18 at 19:51
  • Ok. Very good. Function!! changed '?' by '&' thanks – Texas Apr 1 '18 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.