Hot answers tagged

12

You cannot assign capabilities to unknown users. If you want to make a post visible for everyone, create a separate URL for these posts and add a control element to the post editor to enable the preview on selected posts only. When such an URL is called, check if a preview is allowed for the post and if the post hasn’t been published already. Also make sure ...


7

Since editor displays projected permalink for slug editor, it must have some way to figure it out. From looking at source that is handled by get_sample_permalink_html() and get_sample_permalink(). Since we only need link without form cruft, we can rework it into something like: function get_draft_permalink( $post_id ) { require_once ABSPATH . '/wp-...


7

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 ) ) ); $...


6

I solved this problem in what I thought was a simpler way than @toscho's answer above. My use case is I'm using the same database for an internal intranet staging site and a public-facing site, and the workflow is that authors write drafts and share it with other users who view those drafts on the intranet site, before publishing. I specifically didn't want ...


5

Change published to publish. $args = array ( 'post_type' => 'step_to_hs', 'post_status' => 'publish', ); // The Query $query = new WP_Query( $args ); Reference WP_Query status parameters


5

This is what normal query run by wp_get_associated_nav_menu_items() looks like: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE 1 = 1 AND wp_posts.post_type = 'nav_menu_item' AND (( wp_posts.post_status <> 'trash' AND wp_posts.post_status &...


5

I had a similar problem and here is the best solution I could come up with. The reason (I think) that private or non-published items show up in menus is that the menu items are themselves posts and have their own post_status. That means that in a situation where a page is marked private, the menu item for that page can still be set to publish, and is ...


5

There is probably a better way but you could add the following CSS to your stylesheet, which will add a little banner when viewing a page that has a status of draft. .status-draft.hentry:before { content: "Previewing a Draft"; background: #87C5D6 !important; display: block; text-align: center; } You could also use these classes for the ...


4

This is a really old question, and while looking at some of the plugins mentioned here, I noticed that many aren't maintained or not quite what I was looking for. In the end, I found one I liked called Revisionize. While it's reputation and usage isn't up yet since it's rather new, I like it. Pros: Nice UI within WordPress, buttons are easy to find and ...


4

I used this as a solution for hiding draft pages. You can hide the (draft page) menu items with the li.draft class. add_filter('nav_menu_css_class' , 'nav_menu_add_post_status_class' , 10 , 2); function nav_menu_add_post_status_class($classes, $item){ $post_status = get_post_status($item->object_id); $classes[] = $post_status; return $classes;...


4

Caveat: the code examples within this answer are very basic and may or may not need further conditional logic to adapt to your precise needs, this logic is meant as an example to get you on your way. There's two considerations you need to be aware of: Consideration 1: If you add a new post and save it with a post_status of draft first, the post will not ...


3

The easiest solution is to add a specific class to the menu items that you want to hide. And then hide them through CSS. ^ click to enlarge ^ The CSS classes are not visible by default, you have to enable it in the Screen Options upper tab. If your theme does not print the relevant classes in the <body> tag, this will do: add_filter( 'body_class',...


3

No script of function necessary. It's actually built into WordPress. Simply go to your page to edit and on the right hand side you should see a widget labeled Publish. On the third line down, you will see an Edit button and you can set the date and time on when you want the page to be shown:


3

Just by itself WordPress will not change the post status. However, if you have a plugin like Draft Scheduler installed, drafts will be published automatically, possibly with some interval. So, you should check your plugins on this type of activity. Another possibility would be that a backup of the database has been installed after a crash, but you would ...


2

I also needed this, what I did is hiding it with a custom css : #minor-publishing {display:none;} and here is how to link your css to the admin space : How do I load a CSS style into WordPress admin area only? EDIT: I forgot to say, I combined this solution with : wp_deregister_script('autosave'); to disable the autosave function (this is what the ...


2

There is indeed processing in WP_Query which might prevent posts from displaying if they are not simply public. Since there are several conditions there it is a little hard to guess why it fails in your specific case. It might be issue with how permissions are setup or some edge case (which querying for non-public posts is full of).


2

Hiding them with CSS is problematic, as they still get sent over the wire and still expose what could be sensitive information to anyone who looks at the source, to those who disable CSS for whatever reason (e.g. blind users — CSS just slows them down to no real benefit), and to hacker scripts and the like. No, we need a way to allow menu items to be added ...


2

Quite easily: Go to your Admin Panel --> Posts Select the posts you want to change back to drafts Under Bulk Actions Click on Edit Under Status click on Draft and press Apply Finished If you have more posts, just go through them the same way. :)


2

I would probably create a custom field / check box for this for a draft stage. Then hook into post status transition (or around) and when post is published force it to only private, even if normal publish was pressed. From personal experience custom post statuses are a wreck. They seem like a good idea, but they just introduce mountain more of access and ...


2

The database table for users holds the user_status as integer: $users_single_table = "CREATE TABLE $wpdb->users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varchar(60) NOT NULL default '', user_pass varchar(255) NOT NULL default '', user_nicename varchar(50) NOT NULL default '', user_email varchar(100) NOT NULL default '', ...


2

When I logged out the URL generated a 404. Correct. Why can I see the page when logged in? Is this documented somewhere in the codex? I think this is something that codex has but some parts are still not written, like this part for draft. In the case of draft post your permalink will look like this: ?p=2898&preview=true And it is not available ...


2

It's possible to search within drafts by setting the post_status argument to draft in your search query, however, a better option is to control things with the arguments passed to register_post_type. We first set public to false, which will hide the post type everywhere- front and back end. We then selectively enable show_ui to get the admin UI, and set ...


1

You can hack by adding below lines in your theme's functions.php file. function remove_preview_target() { // below JS code will set Preview button's **target** attribute to **_self**, it means same tab/window. echo "<script> jQuery(document).ready(function(){ jQuery('#post-preview').attr('target', '_self'); }) &...


1

Do you have any kind of cache plugin used? Perhaps to help speed up the website. If Yes that just may be the issue here. Another suggestion is change the current active theme to any default WP theme (twentyThirteen, TwentyFourteen), and then see if Preview give you an issue. If it does not, then its possible that there is an issue with your current ...


1

The reason why your code created drafts only is status='pending' make it publish Like // Prepare to save! do_action( 'wpo_frontend_before_save_order', $order_details, $user_details ); $post = array( 'post_title' => $order_details['title'], 'post_author' => get_current_user_id(), 'post_type' =&...


1

Please review the information here: http://codex.wordpress.org/Roles_and_Capabilities Specifically, the following: Editor – somebody who can publish and manage posts including the posts of other users. An Editor is exactly that - someone who can edit what other people are doing. Ensure that the Users who you want to have Editor rights are assigned as ...


1

You have to POST the data somehow, or send it via GET (not good if you have a lot of data, and not really the intended purpose of GET anyway). It is really hard to tell exactly what your problem is though. The options that come to my mind are: Use the AJAX API (even if the request isn't my by Javascript). Submit to the page you've already created. ...


1

In some cases, the permalink structure must be updated in order for the new template files to be accessed when viewing posts of a custom post type. To do this, go to Administration Panels > Settings > Permalinks, change the permalink structure to a different structure, save the changes, and change it back to the desired structure. from http://codex....


1

I think the best solution, as discussed in chat, is point 3, programmatically adding a draft (or custom post status) via the use of wp_insert_post where amongst other parameters you can set the likes of; 'post_date' => [ Y-m-d H:i:s ] //The time post was made. 'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT. ...without ...


1

This is very similar to this question. We have to hook into check_ajax_referer to address the internal linking feature only. Then we register an action for pre_get_posts to extend the search to drafts and pending posts. We will still get no pretty permalinks, because they are excluded in get_permalink. So we register a filter for that too and ask WordPress ...


Only top voted, non community-wiki answers of a minimum length are eligible