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)
- Not working Mobile view and Desktop view properly when we searched on website
- When i save or publish a post setting reset wp
- Can’t publish custom type posts that don’t support title and editor, instead they’re saved as draft
- Is there any way to draft a revision of a published page or post? What workarounds have you used?
- WordPress Theme Preview Image
- How do I make a draft post accessible to everyone?
- How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
- add action only on post publish – not update
- Approve post directly from preview mode?
- Post preview mechanism architecture
- How to prevent posts from being published too close to each other?
- Hide permalink and preview button and link on custom post
- How can I make it so the Add New Post page has Visibility set to Private by default?
- ‘Preview Changes’ for custom meta boxes?
- Front end form to create a custom post with preview
- View homepage in a preview mode
- Post/Page Preview Template
- How to get the clean permalink in a draft?
- Is it possible to Schedule Attachments in WordPress?
- InDesign to WordPress workflow
- How are WordPress draft previews generated?
- Elegant way to include only published posts with get_objects_in_term()?
- How can I change preview URL?
- How to call a REST endpoint when a post is published?
- wp_delete_auto_drafts() deletes links in menus
- Prevent publishing the post before setting a featured image?
- How can I make post fields required in WordPress?
- Is there a way to set a user profile to Draft?
- Disable device preview options in the block editor
- Exclude Private, Draft pages from Primary Nav when using custom menu
- How to preview your website without the top WordPress admin bar, but remain signed in?
- WordPress plugin to publish to multiple remote WordPress blogs
- Post publish only hook?