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
- What are the ADVANTAGES of ORIGINAL wordpress template structure?
- Change admin bar to default:off
- How to change admin bar color scheme in MP6 / WP 3.8 front end?
- Template for individual post designs
- 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 to disable 3.1 “Admin Bar” via script for the admin user?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- Front End Post Submit Form
- How the WordPress sidebar works
- 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
- 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
- First completely customized theme, where should I start?
- Theme Customizer not loading
- Modify Javascript Configuration Options for Theme Customizer Colour Picker
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Finding Page Template and Displaying Content
- Customizer API and add_panel(). Panel doesn’t show
- How to correctly add JQuery in a WP 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?
- 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?
- Limitations when modifying wp_title with a filter
- How to edit theme functions file to modify pagination?
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- “Add A Widget” button in the Customizer
- Q: How to pull data from custom table to populate zustomizer setting/control select options
- Move default page templates to sub directory
- What’s the best practice way of handling custom fields in different post formats?
- Echo all category names, apart from one
- Is it possible to visually group items on the theme customizer?
- WooCommerce: multiple input field for multiple product variations
- Redirect to another page using contact form 7? [closed]
- Customizer – loading settings/controls/sections/panels based on a id/page id
- Child Theme header1.php file not overwriting parent theme’s header1.php file
- Where WordPress Stores The Custom Fields Values
- How to have content scroll over background
- Change image size depending on page
- Is there a WordPress boolean for “theme_customizer_active()”?
- searchform.php doesn’t work properly
- Twenty Seventeen Pages Loop
- Customizer: get_preview_url() inside customize_save_after hook
- Custom Post type content within a slider
- How to add custom meta box when you have a custom page template file
- add shortcode support in customizer
- How to add post meta fields to an article’s as meta elements
- Right procedure when you develop a WP Website for a client
- How does the loop know which post to view?
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Injecting pre-defined text from custom page template to editor
- Exclude subcategory from wp_query
- Style first 3 posts differently with WP_Query [duplicate]
- Update Specific Key Value in Complex `wp_options` object
- Can’t change theme name
- Pagination and multiple loops
- How to custom category template based on category?
- How to use multiple check-box values to work in a function and insert values in database
- get_the_terms() returning wrong results inside of loop
- Infinite loop when nesting have_posts()
- Remove Custom metabox from particular page template is used
- Problem with Displaying Custom Theme Page’s Content
- HTML TO WP Theme : Submenu goes down wp_nav_menu
- Any way to permanently translate themes?
- How to share posts (and plugins) between existing site and new, separate dev/test installation?
- Customizer API way function is_customize_preview() works only in main page?
- How to show the posts list into a static page? Problems to use the loop into a static page
- Conditional loop based on current page
- Support Multiple featured images
- WordPress 3.5 + Foundation 5 not working on IE9
- What hook to use for loading a custom class extension during Theme initialization?
- Suppress the_content filter in a nested loop
- trying to figure out how to use more that one image upload in the same section in theme customizer
- Simple loop with shortcode rendering problem
- How get the 10 most viewed pages (not post)
- The normal loop with different styles doesn’t work in search.php
- issue displaying variations in custom template using WPeC 3.8.9.2
- Post thats in Two Categories, only want to display name for one
- have_posts() return false on single post
- Permalinks problem with custom theme
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- How to set up a development/staging site to make major changes to the theme then update on the live site?