Figured it out.
$post_obj['permalink'] = my_getDraftPermalink( $post_obj['post_id'] );
That’s the correct syntax for getting the post_id. Then a custom function that gets the permalink the same way as the post dashboard UI is required. The dashboard uses get_sample_permalink
and not get_permalink
, which will return the draft path if the post isn’t live.
function my_getDraftPermalink ( $post_id ) {
require_once ABSPATH . '/wp-admin/includes/post.php';
list( $permalink, $postname ) = get_sample_permalink( $post_id );
return str_replace( '%postname%', $postname, $permalink );
}
Related Posts:
- X-Pingback and XMLRPC
- How to activate plugins for my WordPress sites from a remote server
- How to stop xmlrpc attacks without disabling component to allow JetPack to work in WordPress?
- How to block XML-RPC attack?
- Call specific plugin update
- Using Microsift Word/Outlook for content publishing to WordPress
- Can I disable xml-rpc by setting it to false?
- Can you add a shortcode to a custom post type that gets the post_title, post_content, etc. and then passes that to a plugin function?
- Avoid duplicate posts with xml rpc
- getpost content with all formatting for admin pages
- How to maintain W3C standards compliance of a theme
- Load plugin on specific page only
- Does a plugin’s “main” file need to be named the same as the folder containing it?
- Plugin or mod for wordpress to make content publication SUPER easy
- enqueue script only if it is not already enqueue
- Display (and manage) webcam images?
- Overwrite textdomain of plugins by default – Lost Translation
- jQuery plugin only in one page/post
- Google Analytics post views in WordPress? [closed]
- scheduled event not getting executed
- How can I limit functionality in one version of a plugin?
- Any way to use a custom Parameter for youtube embed without using an iframe?
- Hook (upgrader_process_complete) running moment
- How do I add a template to a theme using a plugin?
- Can’t see login page after migration
- How to import 55k images (uploaded via FTP) into WordPress Media libary? [closed]
- Debugging Technique Question re: functions.php
- Custom Taxonomy Tag Search
- Retrieving plugin options value saved through setting
- An issue with SEO Ultimate
- How do I modify the position of a plugin?
- Add a custom form on the post-new.php admin page
- how to give a user a role?
- looking for navigation plugin (accordion) [closed]
- When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
- Trouble with editing template for “List category posts” plugin
- Upgraded to latest version – 3.0.3 and Now I get a “sufficient permissions to access this page” error
- How to show WP addon installation path during installation?
- Replace default og:image tag YOAST
- Automatic plugin updates not working
- Fromcraft Plugin On click submit button [closed]
- A include_template Question
- flush_rewrite_rules() not working with update_option_{$option}
- PHP if statement with German umlauts [closed]
- How to ignore extra whitespaces in translation functions like _e?
- Can backlinks to my site increase my chances of plugin rejection
- Hide a certain category name from Related Posts
- Price comparison table based on Custom Post Type?
- wp_logout_url($redirect); is not working in wordpress
- How do I determine if the user who registered is not spam?
- display unique post per category
- How to display a widget on a page with no theme?
- How to get a custom page through plugin?
- Filters on the_content with plugins, pages and shortcode
- Plugin to send messages to members/lists but not full-blown newsletters
- Plugin prevents code from working
- Determining Whether Automatic Upgrade will Fail?
- can’t install any wp plugins [duplicate]
- Show an admin menu item in Editor role
- Add Plugin broken after removing Booster for Woocommerce
- WP_CONTENT_DIR disables plugin directory
- WordPress Custom Hook with Class method
- Undefined index: custom_post_template_present
- Ensure WordPress Theme Uninstalls Completely
- Image path in childs theme
- one url for all pages
- Using foreach loop for `$instance` of form and update array widget iteration
- Warning: sprintf(): Too few arguments in nav-menu-template.php
- how to insert thousands of posts faster?
- Redeclare a plugins function/class in my theme?
- Coupon Codes for product discount combined with conditional free shipping
- Avoid enormous network payloads
- How to fix slow comment query?
- How to create a custom control in customizer
- Sanitize AROUND shortcode
- wp meta_query meta_value compare =REGEXP delimited by space
- Sending post data over REST API, how to parse shortcodes in post_content?
- Primary Menu doesn’t show because of w3 cache
- Create shared actions for admin and users with plugin bolierplate
- Plugin Screenshots not showing
- Wp Ecommerce Reposition Product Page Product Thumbnail Image
- It possible to implement an adhoc php web application with wordpress?
- Array to string conversion error when trying to POST multidimensional array
- How to test a WordPress plugin on a single post?
- Hyperlink to execute PHP
- How to get site homepage from plugin?
- Contact Form loaded with Ajax
- Link Forms on WordPress
- How to correct Error: message on website Twitter Feed
- WordPress plugin WP-blocks is adding slashes before apostrophe
- Image rotator plugin
- Automatically set posts to NoIndex depending on category?
- Custom time field won’t sort regardless of format
- Why does theme need woocommerce to show images / content on front page?
- WordPress Hooks : Where to place callbacks that repetitively yield the same effect?
- wordpress Ajax success doesn’t return the value
- Make plugin admin page visible to other roles
- How Create LastMod and Update Date Only on Taxonomy Category and Tags
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?
- Getting 400 Error in wordpress website