Support » Plugin: WP Ultimate Recipe » “Error saving content settings: Invalid page template”

  • Hello,

    We’re having issues using other page templates with your plugin. For some reason it seems like it doesn’t like using anything other than the default template.

    When we try to save using Cornerstone, the front-end editor tool associated with X Theme, we get the error (in the console) of “Error saving content settings: Invalid page template” and it fails to save.

    This is not an issue with any other custom post type and appears limited to just your plugin. The error itself also appears to be coming from your plugin.

    Do you know how we can solve this issue? Is there a way we can choose a template for the plugin for ALL recipes? (And by that I mean a theme template; not a template for just the recipe portion)

    We are trying to just get rid of the sidebar by using our theme’s full-width template, but I don’t see any way to do that.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Brecht

    (@brechtvds)

    The error you mention is definitely not coming from our plugin. Or are you getting any other errors?

    Have you checked with X Theme or Cornerstone support? The theme is responsible for page templates and I honestly don’t see how we can influence this.

    Brecht

    Yes, I worked with Themeco (X Theme authors) and they ran some tests and decided it was 100% your plugin.

    I’m not having any issues with any other posts or even custom post types; just Recipes!

    Is there some other way I can eliminate the sidebar, or otherwise select the overall page template?

    Plugin Author Brecht

    (@brechtvds)

    What did their tests show then? Did they find any errors or something related to WP Ultimate Recipe? Just saying that it’s definitely our plugin doesn’t really get us anywhere.

    I agree with you, but in my experience when the developers of a plugin show that it works fine in other circumstances, but breaks in conjunction with a 3rd-party plugin, they blame that plugin and will not delve deeper.

    They proved that on any other custom post type, you could select the specific page template and it had no issues saving or displaying.

    If it was on the recipes post type with your plugin, it couldn’t save (from within Cornerstone) and the console generated the error already mentioned.

    I did some extensive digging and found the following information, which I will explain.

    Let me lead by saying that if your plugin does anything strange with the default WordPress template functionality, then it is almost certainly to blame. And I know that it does, because I’ve tried to override templates and it behaves very strangely.

    Here is why that is the case.

    I found that the error itself is initially generated by cornerstone\includes\classes\content\class-content.php, lines 111-113, which are:

      if ( is_wp_error( $settings ) ) {
          throw new Exception( 'Error saving content settings: ' . $settings->get_error_message() );
        }

    So Cornerstone displayed the error, however it is simply relaying what is_wp_error gave it, which is a core WordPress function. (Meaning that the error came from WordPress, not Cornerstone) Digging deeper, I found the specific WordPress core file responsible for generating the error “Invalid Page Template”. The file is wp-includes\post.php, and lines 3411-3422 are responsible, which are:

    `if ( ! empty( $postarr[‘page_template’] ) ) {
    $post->page_template = $postarr[‘page_template’];
    $page_templates = wp_get_theme()->get_page_templates( $post );
    if ( ‘default’ != $postarr[‘page_template’] && ! isset( $page_templates[ $postarr[‘page_template’] ] ) ) {
    if ( $wp_error ) {
    return new WP_Error( ‘invalid_page_template’, __( ‘Invalid page template.’ ) );
    }
    update_post_meta( $post_ID, ‘_wp_page_template’, ‘default’ );
    } else {
    update_post_meta( $post_ID, ‘_wp_page_template’, $postarr[‘page_template’] );
    }
    }`

    Nothing jumped out at me from that, so I couldn’t tell why the error is coming.

    Digging in to the database, I found that these posts have a row in wp_postmeta whose meta_key is “_wp_page_template” and the value, in this instance, is “template-layout-full-width.php”.

    Those values are all correct, so why would it be reporting an error?

    Is there some way we could narrow this down or dig deeper to figure out what’s happening? How exactly does your plugin alter the template functionality? If it literally just appends its own or manually manipulates it, then that would likely be where the problem lies.

    • This reply was modified 2 years, 3 months ago by brianjohnsondesign. Reason: Formatting code
    Plugin Author Brecht

    (@brechtvds)

    But we really do not alter anything related to the page template. Page templates are handled entirely by the theme.

    The only thing we do to display the recipe is filter the post_content to add the recipe box to it. Hardly anything exotic.

    If you contact us over at support@bootstrapped.ventures and could send me a copy of the theme I can do some testing as well.

    That all makes sense, which is why it’s odd that there’s an error.

    I have sent you an email at that address for testing.

    We’re exploring other solutions to avoid having to select a template and will hopefully have some luck there, but I’d still be curious to know what the issue here was. Being the number 1 or 2 theme in the World, I’m likely not the only one with this issue!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘“Error saving content settings: Invalid page template”’ is closed to new replies.