Skip Navigation

[Resolved] Duplicate post on front end

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Christian Cox 4 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1411301

I am trying to:
Duplicate post on front end. I follow the solution explained in support thread
https://toolset.com/forums/topic/duplicate-custom-posts-at-front-end/
However, I get an error "Fatal error: Uncaught Error: Call to undefined function add_shortcode() ".

#1412347

Hi, that ticket is a bit outdated. Did you add code to your theme's functions.php file (note it is supposed to be added in functions.php with an "s" at the end), or to a custom code snippet in Toolset > Settings > Custom Code? Can you copy + paste the exact code you added?

#1412703

function duplicate_posts() {
duplicate_post_clone_post_link( __('Clone this Post','duplicate-post'), $before, $after, $id );
}
add_shortcode( 'duplicate_post', 'duplicate_posts' );

#1412775

I have added it to functions.php

#1413529

Normally that error message occurs if you try to execute WordPress code in PHP without loading WordPress. Are you doing any custom AJAX, or loading a PHP file directly without loading WordPress? For example, this person is using a PHP file to display some images. They tried to use add_shortcode inside this PHP file, without loading WordPress code: https://wordpress.org/support/topic/getting-call-to-undefined-function-add_shortcode-for-refreshing-a-div/

#1413631

I have removed the code from the functions.php and added it to toolset Custom Code. The error is not appearing now but when I add the short code to the content template it will not show link to duplicate the post.

#1414231

My issue is resolved now. Thank you!

#1414819

Yes the code Shane shared appears to be an incomplete example. I see you have marked the ticket resolved, do you still need assistance? If so, please reopen the ticket or add a comment here.