Create posts without login from frontend

You should not allow anonymous users to publish anything on your website without authentication. If you need to store custom data that is specified by users, you should use the custom fields instead. In your case, add_post_meta() comes in handy. After creating a post using wp_insert_post(), pass its ID to add_post_meta() and add custom fields … Read more

upload image in a meta box

You may want to take a look at Steve Taylors plugin and his approach here Dominik “ocean90” Schilling – the author of the (new in 3.5) media library, has a GitHub repository where he shows off some demos. In short, you might not be able to implement a drag&drop style media uploader in a meta … Read more

How to Load Scripts and CSS for Admins Only When Editing or Adding Posts

you want to use admin_print_scripts-(page_hook) and admin_print_styles-(page_hook), so in your case: add_action(‘admin_print_scripts-post.php’, ‘call_my_function’); add_action(‘admin_print_scripts-post-new.php’, ‘call_my_function’); add_action(‘admin_print_styles-post.php’, ‘call_my_styles_function’); add_action(‘admin_print_styles-post-new.php’, ‘call_my_styles_function’);

How to control which category will be picked for the slug of a post?

WordPress picks the lowest ID as its main permalink. However, ALL categories will contain your post automatically. Meaning both these: http://yoursite/category-A/post-A http://yoursite/category-B/post-A …will return your post (given that post-A is in both category-A and category-B) via a redirect. It can’t list them all to you on the Edit page, sorry. But it will make sure … Read more

Reverse chronology of post listing

You can add code below to the beginning of loop.php add_action(‘pre_get_posts’, ‘wpse_change_post_order’); function wpse_change_post_order($query){ $query->set(‘order’,’ASC’); $query->set(‘orderby’,’date’); } the oldest posts will be in the home page.

Email admin when post pending?

There a couple of ways you can go about it depending on your use case and although example number 1 is perfectly valid, it might make more sense to employ the use of example number 2. Example #1: This will send you an email each time a post is updated/published with the status of “pending”. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)