Support » Plugin: Developer's Custom Fields » [Plugin: Developer's Custom Fields] error using slt_cf_get_posts_by_custom_first

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Steve Taylor

    (@gyrus)

    Hi Sean,

    First off, I wonder if this plugin might help managing events? http://wordpress.org/extend/plugins/simple-events/

    The more I look at slt_cf_get_posts_by_custom_first(), the more I’m wondering why it’s in the code! I think what you’ve hit is an obvious bug – it should be sorting and returning $posts->posts, not just the $posts query object.

    But past that, doesn’t the usort() with slt_cf_order_posts() just override the previous ordering by custom field?

    Let me know if you come up with anything, but for now I’m thinking this was code I imported from somewhere else, and stupidly didn’t test properly, early on in the plugin’s history before I released it. :-/

    Sean

    (@seanhawkridge)

    Thanks for getting back so fast – I’m giving Simple Events a try.

    I’ve installed and activated it, and already have a custom post type called ‘event’, but the date field is not showing up in the event screen.

    I do already have a bunch of other custom fields registered for events (including one called ‘Date’, which I’ve just removed) – could that be causing a problem?

    Plugin Author Steve Taylor

    (@gyrus)

    Check inside Simple Events, you’ll see how it defines a date field using the DCF plugin. The name of field is event_date, so don’t use that in your own code.

    Sean

    (@seanhawkridge)

    Odd – it’s just not working. No date picker in the admin screen, and no date column in the events list. Can’t figure out why – none of the names clash.

    Plugin Author Steve Taylor

    (@gyrus)

    Busy right now – all I can say is, re-read the Simple Events readme.txt, and try a little basic debugging output from slt-simple-events.php, see what’s what.

    Sorry that’s all I can offer now, keep me posted and I’ll try to have a look when I get time.

    Plugin Author Steve Taylor

    (@gyrus)

    Sean, sorry, I don’t think I’ll be fixing this for now:

    https://github.com/gyrus/WordPress-Developers-Custom-Fields/issues/10

    Hi Sean and Steve,

    I was having the same issue with the plugin. I installed it, check for any namespace conflicts and after discovering no issues started debugging.

    I noticed both the plugin and your register_post_type functions are called on ‘init’ action.
    You need to make sure that WordPress calls your register_post_type function before the plugin ‘init’ action so that the post type exists before the plugin is activated.

    Do this simply by adding a priority of ‘1’ to your register_post_type function, thus:

    function create_my_post_types() {
    	register_post_type( 'event',
    		array(
    			'labels' => array(
    				... labels here ...
    			),
    			'public' => true,
    			'supports' => array( 'title', 'editor', 'thumbnail' ),
    			       ... more options ...
    		)
    	);
    }
    add_action( 'init', 'create_my_post_types', 1, false );

    It works for moe now, so I hope that helps.
    Might be worth putting that as a note in your plugin readme, Steve? Or just add a lower priority to the plugin init action.

    Olly

    Plugin Author Steve Taylor

    (@gyrus)

    Olly, I’m not sure what you’re talking about is relevant to this thread.

    But I see what you mean. The issue of registering custom post types happening after the plugin’s init function has never come up, but I guess this may be pure chance!

    If I’m understanding the issue correctly, I think the best approach would be to change this line in the plugin:

    add_action( 'init', 'slt_cf_init' );

    To:

    add_action( 'init', 'slt_cf_init', 10000 );

    I would probably add a note in the docs too, but at least no one would have to alter their add_action, except in extreme circumstances.

    If you think I’ve understood your problem correctly, could you confirm, and maybe raise it as an issue on GitHub? Thanks!

    Steve,

    Just to clarify, I’m referring to the Simple-Events plugin, not Developers Custom Fields plugin.

    Sean seemed to be having issues getting Simple Events to work and all his symptoms fitted mine exactly, and as I’d managed to sort those out with this fix I assumed it was relevant.

    Adding a priority of 10000 seems like a good idea. Will be happy to submit an issue on the Simple-Events GitHub for you

    Cheers,
    Olly

    Plugin Author Steve Taylor

    (@gyrus)

    OK, I can see the confusion now! Note the title of this thread – it’s about DCF. I suggested he use Simple Events, which Sean had a problem with – I assume it’s the same problem as yours. But the thread is really about the slt_cf_get_posts_by_custom_first function in DCF not working.

    Anyway, it might be worth addressing the init issue on both plugins – thanks for raising this. And glad there’s no probs with DCF 🙂

    Ah, my bad. Sorry for the confusion – I stumbled on this post searching for issues with the Simple Events plugin didn’t notice the title!

    Great plug-ins by the way, I think I’m using most of yours on my WP sites.

    Thanks, Olly

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Developer's Custom Fields] error using slt_cf_get_posts_by_custom_first’ is closed to new replies.