You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened
I'm trying to make use of the functions duplicate_post_get_original & duplicate_post_create_duplicate without success with Yoast Duplicate Post Version 4.5 and Wordpress 6.1.1. The first does not create a duplicate/return the original post. The second seems not to be defined.
duplicate_post_get_original is neither duplicating a post nor returning the original post id. Calling duplicate_post_create_duplicate leads to a fatal/uncaught error: Call to undefined function duplicate_post_create_duplicate()
To Reproduce
Step-by-step reproduction instructions
I've created the folowwing simple test code as page template. Post ID 1 is the "Hello World" Blog Post
A link should be created, to duplicate the blog post with ID 1
The blog post with ID one should be duplicated, but ID of old blog post (ID: 1) should be echoed
Another duplicate should be created. ID of created blog post (ID: 3) should be echoed.
Actual results
The actual output looks like the following.
Before
[Link Text](https://logistik.at-fire.de/wp-admin/admin.php?action=duplicate_post_new_draft&post=1&_wpnonce=63f8d20dd5)
After
Warning
: Attempt to read property "ID" on null in
/homepages/14/####/htdocs/####/wp-content/themes/asset-management/geraet-copy.php
on line
32
Original post: ''
Fatal error
: Uncaught Error: Call to undefined function duplicate_post_create_duplicate() in /homepages/14/####/htdocs/####/wp-content/themes/asset-management/geraet-copy.php:37
Stack trace:
#0 /homepages/14/####/htdocs/####/wp-includes/template-loader.php(106): include()
#1 /homepages/14/####/htdocs/####/wp-blog-header.php(19): require_once('/homepages/14/d...')
#2 /homepages/14/####/htdocs/####/index.php(17): require('/homepages/14/d...')
#3 {main} thrown in /homepages/14/####/htdocs/####/wp-content/themes/asset-management/geraet-copy.php on line 37
duplicate_post_clone_post_link creates the link correctly. On pressing, the blog post gets duplicated.
duplicate_post_get_original obviously does not return anything / null
duplicate_post_create_duplicate seems to be undefined.
Which browser is affected (or browsers):
Chrome
Firefox
Safari
Other:
Used versions
PHP version: 8.0
WordPress version: 6.1.1
WordPress Theme: Own
Yoast Duplicate Post version: 4.1
The text was updated successfully, but these errors were encountered:
Hey @sebastianhodapp , I figured it out. The reason is that this function is only available from the admin area, so it's not available if you call it somewhere else.
If you put the code below in your function, it should work.
Please give us a description of what happened
I'm trying to make use of the functions duplicate_post_get_original & duplicate_post_create_duplicate without success with Yoast Duplicate Post Version 4.5 and Wordpress 6.1.1. The first does not create a duplicate/return the original post. The second seems not to be defined.
duplicate_post_get_original is neither duplicating a post nor returning the original post id. Calling duplicate_post_create_duplicate leads to a fatal/uncaught error: Call to undefined function duplicate_post_create_duplicate()
To Reproduce
Step-by-step reproduction instructions
I've created the folowwing simple test code as page template. Post ID 1 is the "Hello World" Blog Post
Expected results
Actual results
The actual output looks like the following.
Used versions
The text was updated successfully, but these errors were encountered: