Post preview mechanism architecture

Even if you hit just one button for “Preview” it may ends in 2 different “routes”. The one is something like http://example.com/postname/?preview=true The second is something like: http://example.com/postname/?preview_id=152&preview_nonce=xxx&preview=true so the first contains preview query argument, the second contains preview_id preview_nonce preview query arguments. preview query argument tells WordPress to allow visualization of non-published posts to … Read more

Set Default Listing “View” in Admin

Although having the feature of persistent settings in core is nice, it may take quite a while before it’s actually accepted. WordPress 3.5 is still quite far away. So let’s augment the global $_REQUEST array instead. add_action( ‘load-edit.php’, ‘wpse34956_force_excerpt’ ); function wpse34956_force_excerpt() { $_REQUEST[‘mode’] = ‘excerpt’; } This will lock up modes, forcing excerpt mode … Read more

Delete Associated Media Upon Page Deletion

How about this? It adapts an example on the get_posts() function reference page. function delete_post_media( $post_id ) { $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => $post_id ) ); foreach ( $attachments as $attachment ) { if ( false === wp_delete_attachment( $attachment->ID ) ) { // Log failure … Read more

Difference between an archive and a page listing posts

Archive Page An archive page is part of the WordPress Template Hierarchy, and is the template file WordPress uses to display the archive index list for a given post type. The custom post type archive template hierarchy is as follows: archive-{posttype}.php archive.php index.php WordPress uses the query parameters to output this page, and posts are … Read more

simply loop through posts

Because you’re on a page, that’s only going to display the query for that page. As such, you’d have to create a new query to bring in the posts you want. Replace your loop with this: <?php $args = array( ‘post_type’ => ‘post’ ); $post_query = new WP_Query($args); if($post_query->have_posts() ) { while($post_query->have_posts() ) { $post_query->the_post(); … Read more

Changing the post date and time with function

Call wp_update_post() with a special value for ‘post_date’ and ‘post_date_gmt’: $time = current_time(‘mysql’); wp_update_post( array ( ‘ID’ => 123, // ID of the post to update ‘post_date’ => $time, ‘post_date_gmt’ => get_gmt_from_date( $time ) ) );

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