This is probably not the best way to do it since it wont persist after wordpress updates (but hopefully the update will correct it.
In wp-admin/includes/post.php
,edit the post_preview()
function just before returning the apply_filters( 'preview_post_link', $url );
put the following code:
//ORIGINAL
//$url = add_query_arg( $query_args, get_permalink( $post->ID, true ) );
//CHANGES to make the preview work even with postname in the URL
$query_args['p'] = $post->ID;
$url = add_query_arg( $query_args, get_permalink( $post->ID, true ) );
$url = str_replace('%postname%/', '', $url);
//END CHANGES
But still if there is any way to make it better ?
Related Posts:
- How to make scheduled post preview visible to anyone?
- How to unpublish a page and still keep a draft?
- Disable “preview changes” button
- Can we have private drafts?
- I need to modify drafts using custom data from database and then publish it
- How to show or hide a post based on meta_value selection?
- Visual Studio SignTool.exe Not Found
- How can I delay the publishing of a page or post?
- Passing current cookies in wp_remote_get to get Draft Post Preview
- How can I set a draft page as parent without publishing?
- Display a post’s publish date from 2112
- Does blocking xmlrpc.php affect pinging update services like pingomatic
- Can’t preview drafts after upgrade to 4.0!
- Publish post when edit post form submitted with enter/return pressed on keyboard
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- Why does publish_{custom-post-type} fire on update?
- Show recent published posts
- Does WordPress remove draft status automatically?
- Is there a way to know if a post has been published through XML-RPC?
- get_terms on save_post hook
- Save and Publish button not working after installing SSL
- Can I set a timer for pages to be published?
- What differences are there between a Privately Published post and a Draft post?
- How to allow a user to make their post (ad) a draft, and then publish again without needing approval?
- Custom Post Type Draft Preview Goes to 404
- WordPress Comments are automatically publishing
- save imported posts as drafts
- Update post meta on bulk edit / update
- Can’t schedule post for another time
- How to get the Tags on Publish post hook?
- publish_post called too early
- Custom save button shows ‘Are you sure you want to…’ dialog
- wp_publish_post to saved draft, permalinks broken
- Get publish post link?
- Controlled publishing in WordPress
- redirect deleted / drafted pages
- Change the text of the publish button to Save
- problem with publish date not always appearing [duplicate]
- What is happening to make my Update/Publish button disabled?
- Some users getting a 404 when previewing draft posts/pages
- What is the reason for the new_to_publish hook not working?
- After I publish a post where does it go
- Should you manually ping new WordPress posts?
- Authors should not publish
- How to add custom status to quick edit
- i am making text changes on my page show in preview not on live site, why? [closed]
- Is WordPress “publish” atomic?
- How to move post process to background
- Set page to draft on plugin deactivation
- How does redirect work when publish date changes and date in url changes?
- Hook when post is set from published to draft?
- My posts are getting to Auto draft when I try to Publish
- Gutenberg publish date datepicker
- How Google Indexer should only index published pages
- Publish and go to page [duplicate]
- Publish Post Action Not Working
- Is it normal for a scheduled post to say “Missed Schedule”
- Manage multiple wordpress installs (Best Practice)
- Showing the next post’s title, even if it’s an unpublished post
- Force Publish Future (Scheduled) Posts Immediately [duplicate]
- Can’t publish posts, Jetpack won’t connect, empty notification emails to my inbox [closed]
- Save Draft and Preview not working (1 post)
- Return All Post from publish to draft [duplicate]
- Duplicate post on publish
- How is it possible to use a very reduced version of WordPress?
- Problems in updating a self-developed plugin
- when I Try to Create new Post or Page it goes Draft(I can’t post Anything)
- How to prevent posts from being published too close to each other?
- How to preview your website without the top WordPress admin bar, but remain signed in?
- How to access the post meta of a post that has just been published?
- When a user creates a post (pending), send a confirmation link that allows them to publish
- How to change post status in hook?
- Create slugs programmatically
- Check if post is in draft or pending review?
- Limit number of posts a user can make per minute?
- Preview Button Custom
- Which ID does WordPress actually use to display published/drafted posts in preview mode?
- Automatically Updating Publish Date Bug
- Add new post with predefined / preset date
- Show preview posts and pages to clients
- Allow Contributor to edit published post and filter by page id
- How do you manage the Gutenberg block previews in the admin area?
- ‘Archive’ folder for posts and pages
- Do action on publish or update?
- Ajax function on #publish only saves as draft – how to make it publish?
- Making draft page as the main page
- Trim Post Content on Home Page
- Preview page/post revisions without overwriting current content
- Use value from ACF to populate other fields
- WordPress get tags in “publish_post” hook
- Having SSL enabled on admin, but disabled on post preview and live preview?
- Error 404 when saving or previewing one specific page [closed]
- Redirect preview single post link to a page
- Preview own posts if logged in
- How to handle a post before publishing?
- Post publish date [duplicate]
- SQL: Search query to get attachments only of those parents which are published
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- Problems with draft website pages
- Set post to draft if matching word is found in the post