So I ended up just adding the meta after inserting the post, which doesn’t give any error. It bypasses the problem without explaining it though…
$postarr = array(
'post_title' => $link['caption'],
'post_type' => 'ct_external_link',
'post_status' => 'publish',
'post_excerpt' => $link['caption'],
);
$external_link_id = wp_insert_post($postarr);
if( !empty($external_link_id) ) {
add_post_meta($external_link_id, 'ct_external_link_url', $doc['file'], true);
if( isset($doc['hide']) ) {
add_post_meta($external_link_id, 'ct_hide_from_frontent', $doc['hide']);
}
}
Related Posts:
- How to get URL of current page displayed?
- How to update custom fields using the wp_insert_post() function?
- Encode text string being appended as query to URL [closed]
- Is it safe to use $_SERVER[‘REQUEST_URI’]?
- The correct method to pass query vars in AJAX using ajaxurl
- How to check if feed URL was requested?
- What is the best practice for escaping data URIs?
- urlencoding of the_title() doesn’t work?
- PHP/Manual use of images? – 2 Questions
- How do I get the author’s page url from their ID?
- Dynamic URL to reference custom PHP files
- Set Primary category using the Yoast SEO plugin
- Concatenate site_url and string doesn’t work
- What’s the proper way to use wp_enqueue_script/style?
- Newbie question: no index.php? in my plain wordpress permalink
- wp_insert_post not working
- Extract subdomain and relative address from a url
- Remove query string specific key value
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Echo URL of large version of Featured Image
- Why does WordPress remove my variables in the URL?
- Can’t get wp_insert_post to work
- Dynamic content based on a URL parameter
- Auto-Select Parent Category as Primary
- Colon is Missing In My Website Url in WordPress
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- Don’t insert if permalink is the same?
- Extend PHP regex to cover “srcset” and “style” attributes
- My php header() function is not working [closed]
- Scrape external webpage for first image and add it to new post
- Create custom permalinks to show Custom Post Type’s relationship?
- Use of wp_insert_post and parameters
- Getting error when using wp_insert_post()
- Get URL Parameters from referer
- Why is $wp->request empty in WordPress 6.0?
- Get the URL of the page from which an ajax request has been launched within ajax callback
- How to pass a PHP $_GET variable and fetch/output it?
- Post’s ID pattern?
- wp_insert_post() with HTML tags using PHP
- Add new post in existing categories using wp_insert_post
- I’m unable to call img path using single quotes in an array?
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- get post id from wp_insert_post for get_template_part
- Returning all values from foreach in function php [closed]
- Generate CSV file and add data as a new wordpress custom post
- change default RSS feed URL
- How do i add slugs to a URL, but still redirecting to the same page
- Nginx WordPress and another Web app URL structure
- how to get attached file url for current post?
- How to use `wp_insert_post()` and `get_permalink()` functions?
- Call featured image url
- Creating customized php files in theme folder
- How do I include an external PHP file in a subdir WordPress install?
- Use an anchor link to open an iframe inside a WordPress page
- Adding custom url to readmore link using get_permalink()
- How to set base url for php widget
- Comment_author_url doing nothing
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- WordPress is removing query variables like page, p from the URL of a custom static page
- Workaround for og:image unsupported webp image type, Yoast SEO?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Unable to display multiple parameters from url by javascript through shortcodes
- Allow two posts (from different categories) to have the same slug
- Prepend to all image URLs with PHP, only for mobile devices
- Get nice name of category from slug (remove dashes of category)
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- How can I pass php code as a content while publishing a post
- Add Link to PHP message
- Current WordPress Page Title as Search Parameter into A Tag
- Rewrite rule not working, but only when parameter is text
- Get WordPress username to customize url
- WordPress/NGINX not respecting the category URL for new posts
- How does one make a URL return dynamic JSON with custom Content Type?
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- how to call other plugins once custom post has been inserted
- Need to Echo A Url path to show on a wordpress page
- Adding user meta to post meta wp_insert_post() not working
- I want url from a file in media using title file
- How do I generate formatted permalinks as specified in backend options?
- changing static link to relative link
- Create a dynamic buddupress tab
- Front end post submissions do not get submitted in the category
- Removing all my hardcoded URLs with get_site_url()
- Magento and WordPress URL integration [closed]
- Passing multiple variables through url (php)
- How to remove parent section in an attachment URL in wordpress?
- upload images on front by user using form
- Whats wrong with my code? Need To add String to shortcode? [closed]
- Remove /category/ from category (archive) page URLs (without using a plugin)
- WPMU – How to echo only one URL
- append special url end of my website urls
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- How can I change the URL via add_rewrite_rule()
- How to create a WordPress PAGE in another folder?
- PHP – Multiple variables in insert post array
- Can’t send form data to wpdb when URL has query string
- Create a custom plugin with dynamic child pages listing database records
- Can’t insert into a database wordpress