duplicate_post_get_original & duplicate_post_create_duplicate not working
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 53
- Forks
- 38
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
- 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
<?
duplicate_post_clone_post_link("Link Text","Before","After",1);
?>
<br><br>
<?
$original_post = duplicate_post_get_original(1);
echo "Original post: '" . $original_post->ID . "'";
?>
<br><br>
<?
$old_post = get_post(1);
$new_post_id = duplicate_post_create_duplicate($old_post);
echo "New post: '" . $new_post_id . "'";
?>
Expected results
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the public definitions and usages of duplicate_post_get_original, duplicate_post_create_duplicate, and duplicate_post_clone_post_link in the plugin. Compare those entry points with the reported WordPress 6.1.1 and plugin versions, then verify the documented behavior against the supplied reproduction and expected post IDs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100