I am trying to: Create a new post type, Video, and when I go to view a new post under this type there is a critical error happening. In the page for viewing the post it is crashing when it gets to these two lines (if I remove the first, it will crash on the second).
<?php echo do_shortcode('[wp custom_taxonomy="video-category"]'); ?>
<?php echo do_shortcode('[wp custom_taxonomy="videotag"]'); ?>
I took all defaults when creating the post type, and have deleted and recreated it multiple times.
Link to a page where the issue can be seen:
hidden link
I expected to see:
A blank post and just work.
Instead, I got:
Critical error.
Hi,
Thank you for contacting us and I'd be happy to assist.
Have you checked the server's error logs for any detailed errors or warnings?
( ref: https://wordpress.org/support/article/debugging-in-wordpress/ )
To troubleshoot this, I'll need to see how this page is set up in the admin area. Can you please share temporary admin login details along with the information about the shortcode [wp custom_taxonomy="video-category"] that you're using? Is it from a third-party plugin, theme, or part of custom code?
Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details.
I've performed some tests on my website with a similar code and setup as your website, but couldn't reproduce this error. This suggests that something specific to your website is involved.
Do I have your permission to download a clone/snapshot of the website? This will help us in investigating this error in more detail, without affecting the actual website.
Thank you for the permission and I've downloaded the website's clone.
I'll be performing some tests on this clone and will share the results, as soon as this testing completes.
Thank you for your patience.
Thank you for waiting.
I noticed that in the child themes "single-video.php" file at line# 124, the custom shortcode "wp" is trying to call the terms from a taxonomy "video-category", that doesn't exist on the website:
<?php echo do_shortcode('[wp custom_taxonomy="video-category"]'); ?>
Please use a taxonomy slug that exists, for example, "category" and it will show the attached taxonomy terms correctly, without any error:
<?php echo do_shortcode('[wp custom_taxonomy="category"]'); ?>
Additional tip: You can update the custom shortcode in the child theme's "functions.php" file so that in case of an incorrect taxonomy slug, it properly shows the error message and doesn't result in the critical/fatal error:
function list_terms_custom_taxonomy( $atts) {
extract( shortcode_atts( array(
'custom_taxonomy' => '',
), $atts ) );
global $post;
$term_output = get_the_term_list( $post->ID , $atts['custom_taxonomy'], '<li>', '</li><li>', '</li>' );
ob_start();
if ( is_wp_error( $term_output ) ) {
$error_string = $term_output->get_error_message();
echo '<p>' . $error_string . '</p>';
} else {
$string1 = '<ul class="tax">';
$string1 .= $term_output;
$string1 .= '</ul>';
echo $string1;
}
return ob_get_clean();
}
add_shortcode( 'wp', 'list_terms_custom_taxonomy' );
I hope this helps and please let me know if you need any further assistance around this.
So I added the video category, and it did not rectify the challenge. Where is the video category supposed to be added?
I've checked your website and the correct taxonomy slug is added in the "single-video.php" file.
The shortcode is not showing any category because no category is assigned to them. I've selected the "video" category for the "Test Video" post and it is now showing on the front end.
( ref: hidden link )
Screenshot back-end: hidden link
Screenshot front-end: hidden link