Giter VIP home page Giter VIP logo

Comments (3)

Robbertdk avatar Robbertdk commented on July 24, 2024

@sermalefico Thanks for your feature request. To understand it correctly: You want to have the sorting always the same way by adding a sorting method via the shortcode? Or do you want buttons that change the sorting when you click on it?

from wordpress-ajax-filter-posts.

sermalefico avatar sermalefico commented on July 24, 2024

either way would be fine. For example with the sortcode you could choose which buttons appear and with their default value. But yes, these buttons when pressed should modify the order with ajax.

ex:
[ajax_filter_posts post_type="recipe" tax="meal_type, food_type, diet_type" posts_per_page="12" orderby="menu_order" order="ASC"]

or

[ajax_filter_posts id="myquery" post_type="recipe" tax="meal_type, food_type, diet_type" field_as="select,checkbox,radio" posts_per_page="12" ]

[ajax_filter_posts id="myquery" field_as="select,checkbox,radio" filter_button="orderby" value="name" order="ASC" ]

ID: Order by post id.
author: Order by author.
title: Order by title.
name: Order by post slug.
type: Order by post type.
date: Order by date.
modified: Order by last modified date.
parent: Order by post/page parent id.
rand: Random order.
comment_count: Order by number of comments.
menu_order: Order by Page Order
meta_value: Sort by the value for a meta key (or custom field). This only works if you also include a meta_key parameter in your arguments. Meta values are sorted alphabetically and not numerically (so 34 will come before 4, for example).
meta_value_num: Order by numeric meta value. As with meta_value, you must also include a meta_key argument in your query.
post__in: Preserve post ID order given in the post__in array.

I don't know if it's the best way ...

from wordpress-ajax-filter-posts.

Robbertdk avatar Robbertdk commented on July 24, 2024

I think a default sorting option would be a good addition. For example order by title does fit in the uses cases I see for this package.

Although I like the idea of having buttons which control the sorting, I think it makes this package more complicated than it should be. The idea of this package came from the common need to have an overview were a user can filter a list of post (e.g. books, products, cars) and that writing the same functionality over and over again was cumbersome. Therefore I wanted shortcode which can do that, and do just that right, so it saves time developing.

That's also the reason this is not in the plugin repo: it's not a fully fledged plugin.

I'll add the enhancement for the default sorting to his package when I have time. Meanwhile you can add it yourself via the ajax_filter_posts_query_args filter. See https://github.com/Robbertdk/wordpress-ajax-filter-posts#query-arugments for more info.

If you need the functionality of sorting buttons: feel free to fork this package and add the additional features.

from wordpress-ajax-filter-posts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.