Why not do it via URL parameter? You said you can’t because Codex told you not to. But if you want to anyway, you could use a GET parameter:
// http://example.com/page-slug/?direction=DESC
if($_GET['direction'] == 'DESC'){
$order="DESC";
} else {
$order="ASC";
}
$args = array(
...
...
'order' => $order,
);
Related Posts:
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Displaying recent post excerpts on static front page
- How do I Add images uploaded in the post to a default custom field
- Not Found when using activity stream as front page with BuddyPress
- When to use is_home() vs is_front_page()?
- Using classes instead of global functions in functions.php
- How to add a checkbox element to attachments editor with example
- Get ‘page’ number with infinite scroll
- What are the ADVANTAGES of ORIGINAL wordpress template structure?
- Change admin bar to default:off
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- How to change admin bar color scheme in MP6 / WP 3.8 front end?
- Template for individual post designs
- Why doesn’t /2013/01/ properly return January’s archives in archive.php?
- Strategy to get post meta for use outside the loop
- When to use esc_url, esc_html, esc_attr, and friends?
- Best practices – Should I create a child theme vs. customizing a framework theme? (such as HTML5 reset)
- How can you develop on a live WordPress installation that is using W3 Total Cache? [closed]
- How to disable 3.1 “Admin Bar” via script for the admin user?
- Grab the first paragraph of each post
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- Single Page WordPress Theme – Using page templates
- Front End Post Submit Form
- A two column loop with one lead post
- Feature Survey – What would you want in a resume theme?
- How the WordPress sidebar works
- Should we localize custom-made themes / plugins?
- Extend walker – navigation, adding data attribute to a tag
- How can I remove the Static Front Page option from the Customizer
- First post of each category
- Is there any need to use both wp_reset_postdata and wp_reset_query together?
- Set front page as static page [closed]
- query posts in wordpress
- How to programmatically bring back “excerpts” field in post editor in WP 3.1+
- How can i customize the comment list
- Getting Permalink within the loop
- How to add custom template tag in wordpress theme?
- How should I store global information such as a phone number so that it is editable through the CMS?
- When developing a distributable Theme, does it HAVE to be “inheritable”?
- the_content() in single-{post-type}.php problem
- How to handle theme customization and sass variables
- wp_enqueue_scripts not called on search page?
- wp_head() not inserting the default stylesheet style.css
- Upgrading a custom theme through the Dashboard
- Why does this loop only work on the homepage?
- Setting hero/splash section as a blog post
- posts_nav_link(); not showing up on static pages
- Why is unfiltered html allowed in custom fields for author / contributor roles?
- First completely customized theme, where should I start?
- WordPress how to override function adjacent_posts_rel_link_wp_head() in link-template.php the correct way
- Theme Customizer not loading
- Responsive Images – Generating multiple images from Theme Customizer control upload?
- Modify Javascript Configuration Options for Theme Customizer Colour Picker
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Using the theme options to change background
- Best approach to create sites with Modular Content? [closed]
- Modify the Additional CSS section (adding a disclaimer)
- Finding Page Template and Displaying Content
- What’s the best action to use when you want to do something only once per theme setup?
- How WordPress converts URL to $query_string
- Version control for both Vagrant config and themes being developed [closed]
- Customizer API and add_panel(). Panel doesn’t show
- How to correctly add JQuery in a WP theme?
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Link won’t show using the_permalink();
- wp_editor() usage in custom meta box
- Creating multiple hooks for theme
- Some doubts about how to show posts in a custom theme?
- Force index.php have_posts() loop to exit if no sticky posts found
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- Why is the Links Manager visible?
- How to insert content from another Custom Post type into Post?
- Best way to start becoming a wordpress developer
- How to add a second stylesheet to the editor
- Removing non native customizer settings from a child theme
- How to reorganize the items returned by wp_list_comments()?
- Custom Field returning Numerical Value for Image rather than URL
- which is the best way to customize nav-menu-template.php?
- Where should I update_options in a theme?
- WP 3.1 upgrade breaks AutoFocus+ theme
- show a post from a specific post format
- paged > max_num_pages won’t throw 404
- Custom post fields
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- Conditional statement to show pagination
- How to make theme elements customizable in wordpress?
- How to create a custom template to admin dashboard
- Limit Loop to 5 Posts?
- How to add a button which saves the post then executes a function
- Limitations when modifying wp_title with a filter
- How to make animated intro?
- How to edit theme functions file to modify pagination?
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- How to show user online status on their posts?
- Custom Field created in add_meta_boxes reappearing itself again in the default Custom Metabox
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- How to display all subpages and short by year
- Custom get_the_excerpt() only works on first post
- Getting custom posts by post id from cutomizer text input
- Disabling Customizer Selective Refresh shortcut icons for selected controls