Forums

posts orderby custom field (10 posts)

  1. jord_t
    Member
    Posted 1 year ago #

    How would you go about setting the order of the posts using a decimal value in a custom field? I am aware that you would attach your own function to the posts_orderby filter, i have done this and found it easy to order using values in the wp_posts table. I am struggling to do this using a custom field from the wp_postmeta table, would i need to be using the posts_where and posts_join filters also?

    Cheers

  2. musnake
    Member
    Posted 1 year ago #

    Jord, is there a special reason not to use one of the my_post_order plugins? There may even be some ajaxy goodness out there...
    Is this a special integration issue?

  3. jord_t
    Member
    Posted 1 year ago #

    Have you got a link to a specific plugin by any chance? Did do a plugin search but couldn't find one that fitted the above problem.

    Cheers for reply btw

  4. syncbox
    Member
    Posted 1 year ago #

    I'd love to check out a post order plugin... which is a good one for v2.6.+?

  5. musnake
    Member
    Posted 1 year ago #

  6. jord_t
    Member
    Posted 1 year ago #

    Can't really find a decent plugin for my requirement, so gona probably end up writing my own. Gather inspiration from the above plugin.

  7. Dgold
    Member
    Posted 1 year ago #

    if you can make your plugin public, that would be cool, to have another option / another way :)

  8. gabi83tm
    Member
    Posted 8 months ago #

    I'm also looking for a way to use a meta_key with the posts_orderby filter.

    I know it's possible. I've checked it out in wp-includes/query.php

    I just don't know the syntax. There's no documentation for this filter :(

  9. gabi83tm
    Member
    Posted 8 months ago #

    See, no documentation:

    http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby

    Can someone please write it... ?

  10. boldhand
    Member
    Posted 2 months ago #

    Check this link
    http://codex.wordpress.org/Template_Tags/query_posts

    a way to use a custom field to sort and filter posts.

    for example:
    query_posts('meta_key=color&meta_value=blue');

    Returns posts with custom fields matching both a key of 'color' AND a value of 'blue'

    query_posts('meta_key=color');
    Returns posts with custom fields matching a key of 'color'

    query_posts('meta_key=YOURNAME&orderby=meta_value');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.