Adding featured image to a new post using front-end form?

Updated I’m not sure how to do it without ContactForm 7 plugin, but here’s my past code on how to do it in CF7: Assuming your file field is [file your-file]. add_action( ‘wpcf7_before_send_mail’, ‘my_cf7_save_featured_image’, 10, 2 ); function my_cf7_save_featured_image( $instance, $result ) { require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); // Get … Read more

Save post action is called twice

I noticed there was a 302 redirect in my network tab while saving. Save_post was being triggered twice, once from Inside my call, I simply included: $referrer = wp_get_referer(); if (strpos($referrer, ‘http:’) !== false) { error_log(“not the right referrer, aborting”); return; } Issue solved.

Manually adding current_page_parent to wp_list_pages()

By default wp_list_pages() uses the Walker_Page class to create the HTML list, and there’s a filter in there—page_css_class—for the CSS classes. You should be able to do something like this: /** * Filters the CSS classes. * * @param array $css_class The current CSS classes. Array of strings. * @param WP_Post $page The current page … Read more

URL issue retrieving Custom Post Types using Backbone JS API

Actually, you don’t have to extend the Post model (wp.api.models.Post) or Posts collection (wp.api.collections.Posts) because the documentation says: you will get new models and collections when you add REST API support to your custom post type And that means, your custom post type will be automatically added to the wp.api.models and wp.api.collections list, i.e. wp.api.models.<key> … Read more