Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter KS Web Designer

    (@ks-webdesignercom)

    I’m afraid I couldn’t tell you – I cheat and use a plugin for my custom post types, makes it easier to manage having a nice interface to deal with the custom fields and all that.

    Sorry. I can give you the name of the plugin though, and the guy that made it is incredibly helpful and would probably be happy to give you some advice for getting yours to work with custom posts.

    Plugin Author Lester Chan

    (@gamerz)

    I see, no worries, thank you =D

    Thread Starter KS Web Designer

    (@ks-webdesignercom)

    No problem – thanks for all your help ??

    What exactly did you replace < CUSTOM_POST_TYPE_NAME> with?
    I tried you solution here, and replaced it with what I know that name name of my custom post type is. (url structure post types is: ….post_type=”<custom_post_type_name>”) But in the Widget Is still only see “Include ratings from: posts & pages, posts only, pages only”.

    Maybe I’m still missing a step…

    Could you help?

    I created the custom post types using the TYPES plugin.

    Thread Starter KS Web Designer

    (@ks-webdesignercom)

    I replaced <CUSTOM_POST_TYPENAME> with the name of my custom post type. So let’s say you made a new custom type called ‘shop_item’ the code I posted above would look like this:

    ### Function: Add Rating Custom Fields
    add_action('publish_post', 'add_ratings_fields');
    add_action('publish_page', 'add_ratings_fields');
    add_action('publish_shop_item', 'add_ratings_fields');
    function add_ratings_fields($post_ID) {
    	global $wpdb;
    	if(!wp_is_post_revision($post_ID)) {
    		add_post_meta($post_ID, 'ratings_users', 0, true);
    		add_post_meta($post_ID, 'ratings_score', 0, true);
    		add_post_meta($post_ID, 'ratings_average', 0, true);
    	}
    }

    I’m afraid I can’t comment on the way this affects the widget as I’m not using it, I was creating some custom templates with these features built in.

    But I hope that helps.

    Is there a way to modify this function so that it adds the post meta to all of my thousands of already published custom type posts? Or is there any chance of this being included in a future release of this plugin? I would love to be able to sort by highest rated while still keeping unrated items in the results. Thanks!

    Thread Starter KS Web Designer

    (@ks-webdesignercom)

    I thought this did just that… I am using it in a slightly different way now due to the way my own site has evolved but I thought at the time it did list all posts (including those with no ratings)

    From the code it would seem this adds the necessary fields when a new custom type post is published, but doesn’t go back through all posts that were published before this function was instated.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘URL Query string to order posts by highest score missing posts’ is closed to new replies.