Deyaan
Member
Posted 6 months ago #
Hi!
Is there a way to make draft posts to behave just like published ones but without changing the post status from "draft"? I mean to normally show on the web site and be crawled by search engines.
Maybe a plugin or a hack? Since administrator and author of the post can see the draft post, maybe it could be easy to hack that part of the code (I don't know where it is) and allow everyone to be able to see it... I suppose :)
Please help!
Thanx!
add a corresponding query before the loop:
http://codex.wordpress.org/Function_Reference/query_posts
http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters
for example, add this before the loop (of index.php ?):
<?php global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_status' => array('publish', 'draft') ) );
query_posts( $args ); ?>
Deyaan
Member
Posted 6 months ago #
Thanx for the quick response.
Wouldn't only administrator and the post author be able to see the drafted post with that solution again?
I'm looking for drafted posts to be visible to everybody... as normal published posts are.
Deyaan
Member
Posted 6 months ago #
Maybe more accurate description is: I want drafts to be visible to public.
i'm sorry, your idea is really weird.
what your goals actually?
ClaytonJames
Member
Posted 6 months ago #
Maybe more accurate description is: I want drafts to be visible to public.
That's what the code alchymyth gave you does. It makes posts that are in Draft status, visible to anyone. You just have to make sure it's placed before the loop.
Deyaan
Member
Posted 6 months ago #
I'm aware that it sounds weird, but I need it.
Is there a way to change that in the core? Functions? Because my loops are already customized and don't believe I can modify them.
ClaytonJames
Member
Posted 6 months ago #
cause my loops are already customized and don't believe I can modify them.
It gets added before the loop.
Open your themes index.php and find this:
<?php if ( have_posts() ) : ?>
Try pasting the code alchymyth gave you directly above it and save the changes. Check and see if your posts that are in draft status are now displayed.
Don't forget to make a backup before you start editing.
Deyaan
Member
Posted 6 months ago #
Unfortunately it doesn't work :(
I'm trying to use it in "single post" but unsuccessfully.
I found register_post_status for drafts in post.php and if I ad 'public' => true than drafts are shown to public... but now I just want them to show in single page posts, not everywhere.
for single posts, I found this plugin http://wordpress.org/extend/plugins/show-future-posts-on-single-post/
you could either use the plugin, or extract the code (only a few lines) and add it to functions.php of your theme.
the other posted code should work in index.php, and archive pages.
Deyaan
Member
Posted 6 months ago #
At first I wanted to use it on index.php too, but now changed my mind and will use it only for single post.
This plugin does the job! Thank you very much for your effort.
Kind regards!
owh, so your purpose is future post?
:)
Deyaan
Member
Posted 6 months ago #
It's not future, just drafts. I don't know how and why this plugin (code) works for drafts also, but it works :) Maybe futures are just drafts until they are published?
both are different.
you can check in the db
future post => post_status = future
draft post => post_status = draft
both can't be accessed by robot or visitor.
but can be accessed by administrator, editor and author.
Deyaan
Member
Posted 6 months ago #
I noticed, but after installing http://wordpress.org/extend/plugins/show-future-posts-on-single-post/ drafted posts can be accessed by all visitors. I guess by bots also... at least I hope so for SEO reasons.
Edit: Sorry, I checked now and no, drafts are not visible at first. They are only visible (with this plugin) when I publish the post and then mark it as draft. That is actually just what I needed.
btw, it is working now.
that's fine.
:)