Front-End Post Submission

<?php $postTitle = $_POST[‘post_title’]; $post = $_POST[‘post’]; $submit = $_POST[‘submit’]; if(isset($submit)){ global $user_ID; $new_post = array( ‘post_title’ => $postTitle, ‘post_content’ => $post, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, ‘post_type’ => ‘post’, ‘post_category’ => array(0) ); wp_insert_post($new_post); } ?> <!DOCTYPE HTML SYSTEM> <html> <head> <meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” /> <title>Untitled Document</title> </head> … Read more

display all posts in wordpress admin

It doesn’t, in the top right under screen options it says, Show on screen, you can set this to a max of 999 ( I have never tried 999 just fyi) and you can select all, then bulk actions—>edit—>apply. Also I think there are plugins that do this that use direct wpdb functions, so you … Read more

The next_posts_link() works only with original $wp_query

next_posts_link and previous_posts_link use the global $wp_query. function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523 That means you need to do something like this to get those to work correctly. $orig_query = $wp_query; $wp_query = new WP_Query($args); // the rest of your code $wp_query = $orig_query; If you are … Read more

Disable Attachment Pages Completely

You can filter default rewrite rules and remove those for attachments: function cleanup_default_rewrite_rules( $rules ) { foreach ( $rules as $regex => $query ) { if ( strpos( $regex, ‘attachment’ ) || strpos( $query, ‘attachment’ ) ) { unset( $rules[ $regex ] ); } } return $rules; } add_filter( ‘rewrite_rules_array’, ‘cleanup_default_rewrite_rules’ ); Don’t forget to … Read more

Post featured image column on admin post list page

This is what I’m using, cobbled together from snippets found online… It’s uses a filter on manage_posts_colummns to re-jig the headers and an action on manage_posts_custom_column to add the row level data. function custom_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘featured_image’ => ‘Image’, ‘title’ => ‘Title’, ‘comments’ => ‘<span class=”vers”><div … Read more

Passing current cookies in wp_remote_get to get Draft Post Preview

I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source: $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( ‘preview_post_link’, add_query_arg( ‘preview’, ‘true’, $preview_link ) ) ); $cookies = array(); foreach ( $_COOKIE as $name … Read more

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