I want to edit a post using CRED. I created a CRED Edit form called: "Edit Resource" .
I also created a Views Content Template that I use to view posts. This Template does have sidebar.
In this Template, I inserted the following:
[cred_link_form form="Edit Resource" text="Edit %TITLE%" target="_self"].
When viewing a post , I do see the Edit link and when clicked, the Post turn into the CRED edit form with all the appropriate field open for editing. However, the same template used to show the post is used to display the CRED edit form and that includes the sidebar.
I would like to use a different template with no sidebar when you click on the Edit link. You see, my CRED form is complex and I do need the full width of the screen to display the various custom fields that needs editing. So when viewing a post, the sidebar should show and it does, but when edit the post, I do not want to see the sidebar.
Please consider following code to use a different template for CRED Edit form. Please put this code in your active theme's functions.php and make adjustments accordingly:
add_action( 'template_redirect','show_full_width_cred_edit_form',50);
function show_full_width_cred_edit_form() {
if (isset($_GET['cred-edit-form'])) {
//Check if we are editing page
$id=$_GET['cred-edit-form'];
$post_id=intval($id);
if ($post_id > 0) {
//Post ID exist, we are editing page.
//Let's define full width template path
$stylesheet_directory=get_stylesheet_directory();
$template_path=$stylesheet_directory.DIRECTORY_SEPARATOR.'template-fullwidth.php';
if (file_exists($template_path)) {
include($template_path);
exit();
}
}
}
}
Please notice that 'template-fullwidth.php' should be replaced with your particular full width template (.php) file.
Le sujet ‘[Fermé] CRED Edit Form: Who do I use a different page template to edit an existing post’ est fermé à de nouvelles réponses.