Hot answers tagged previews
8
Here is something i have laying around:
<?php
/*
Plugin Name: Approve From preview
Plugin URI: http://en.bainternet.info
Description: Approve from privew is Plugin that lets yo approve posts (draft and pending) from the preview itself.
Version: 0.1
Author: Bainternet
License:
Copyright 2012 Bainternet (admin@bainternet.info)
This program is free ...
4
You should install any program - for example MAMP - that allows you to use Apache and MySql. Then go to wordpress.org and download the latest copy of wordpress. Install it and upload your theme in the wp-content/themes folder.
4
You could use the conditional is_preview() to add a bit of extra content.
For instance, you could put this at the very top of your single.php right after the header is called - or you could put it in your header.php file if you want it shown at the very top of the page:
<?php
if ( is_preview() ) { ?>
<div>You're viewing a ...
3
Draft previews
Take a quick look at this chunk of core code in query.php which
[Checks] post status to determine if post should be displayed.
http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php#L2658
if ( ! is_user_logged_in() ) {
// User must be logged in to view unpublished posts.
$this->posts = array();
}
...is what ...
3
Here's a way to do it without modifying the core:
add_action('admin_footer','preview_same_window');
function preview_same_window(){ ?>
<script type="text/javascript">
jQuery(function($){
jQuery('.preview.button').unbind().removeAttr('target');
setTimeout(function(){
...
3
Look somewhere after the "Loop" starts (it starts with <?php while( have_posts() ): the_post(); ?>) in your index.php file.
Find <?php the_content(); ?> and change it to <?php the_excerpt(); ?>. If you don't want any content, just remove the_content() all together.
If you're using a theme from wordpress.org, it would best to do this in a ...
2
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 ) ) );
...
2
I run through exact same issue. Later I come to know that custom post type I created was not public and hence it does not have 'Preview Changes' button visible.
Prior version of Wordpress was displaying that button but it seems they have fixed it now.
To fix it, make sure you set 'public' to 'true' in array of arguments you are passing to ...
1
The only way I found to make it work is to implement the 2nd patch suggested in this trac ticket
I know it's a patch in the core files, but in the next version of WP (3.6), the change is supposed to be comited, so there shouldn't be any problems with updates.
Edit
Note/Disclaimer: The following mini-plugin was ripped out of Daniel Bachhubers "Edit-Flow" ...
1
There is the handy is_preview function.
So somewhere in your single.php.
<?php
if (!is_preview()) {
// Show stuff that doesn't belong on a preview.
}
1
Open the wp-config file and replace the line that reads define('WP_DEBUG', false); with:
if ( isset($_GET['debug']) && $_GET['debug'] == '1' ) {
define('WP_DEBUG', true);
} elseif ( isset($_GET['debug']) && $_GET['debug'] == '2' ) {
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
} elseif ( isset($_GET['debug']) && ...
1
It sounds like you need a second loop on your home page to call the 3 most recent posts. Try something like this:
// Main home page content here
<?php $my_query = new WP_Query( array( 'posts_per_page' => 3, 'nopaging' => true ) );
while ( $my_query->have_posts() ) : ( $my_query->the_post() ); ?>
<div id="preview">
<div ...
Only top voted, non community-wiki answers of a minimum length are eligible