Site logo

[Resolved] nonce_failure

Home Forums Support [Resolved] nonce_failure

Home Forums Support nonce_failure

  • This topic has 11 replies, 2 voices, and was last updated 4 years ago by David.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1964119
    Philippe

    Hi,

    I might have messed up in the GeneratePress Child: functions.php. Even though I did revert things back to what they were, I still get a nonce_failure error message. Here is below what I have in the file at present. Thanks for your help!

    <?php
    /**
    * GeneratePress child theme functions and definitions.
    *
    * Add your custom PHP in this file.
    * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
    */

    function generatepress_child_enqueue_scripts() {
    if ( is_rtl() ) {
    wp_enqueue_style( ‘generatepress-rtl’, trailingslashit( get_template_directory_uri() ) . ‘rtl.css’ );
    }
    add_action( ‘after_setup_theme’, ‘tu_category_specific_post_navigation’ );
    function tu_category_specific_post_navigation() {
    add_filter( ‘generate_category_post_navigation’, ‘__return_true’ );
    }

    }
    add_action( ‘wp_enqueue_scripts’, ‘generatepress_child_enqueue_scripts’, 100 );
    add_filter(‘pre_get_posts’, ‘excludeCat’);
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set(‘cat’, ‘-43, -44’);
    }
    return $query;

    }

    #1964127
    David
    Staff
    Customer Support

    Hi there,

    where are you getting the nonce_failure – is it in the Theme Editor ?

    #1964201
    Philippe

    Yes, in Theme Editor. WP allows going back to the previous settings, so I have no nonc_failure anymore.

    I would like to get rid of the functionality that prevents certain categories of posts from appearing on the homepage (I use a plugin now, to discriminate post by post). How do I do modify the settings below?

    <?php
    /**
    * GeneratePress child theme functions and definitions.
    *
    * Add your custom PHP in this file.
    * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
    */

    function generatepress_child_enqueue_scripts() {
    if ( is_rtl() ) {
    wp_enqueue_style( ‘generatepress-rtl’, trailingslashit( get_template_directory_uri() ) . ‘rtl.css’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘generatepress_child_enqueue_scripts’, 100 );
    add_filter(‘pre_get_posts’, ‘excludeCat’);
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set(‘cat’, ‘-43, -44’);
    }
    return $query;
    }

    add_action( ‘after_setup_theme’, ‘tu_category_specific_post_navigation’ );
    function tu_category_specific_post_navigation() {
    add_filter( ‘generate_category_post_navigation’, ‘__return_true’ );
    }

    #1964206
    David
    Staff
    Customer Support

    Log out of your site, and close down any browser tabs you have the site open up on. For safe measure clear any browser caches and cookies for that site.

    Then log back into your site and try editing your files.

    #1964209
    Philippe

    Ok. Should I do that right now, before modifying the script I gave you?

    #1964229
    David
    Staff
    Customer Support

    Yes 🙂

    #1964243
    Philippe

    Done. But I am not sure we are speaking about the same thing. How do I get rid of the code functionality preventing certain categories from appearing on the homepage without getting a nonce_failure?

    #1964262
    David
    Staff
    Customer Support

    If the error keeps returning you will need to edit the functions.php file on your server, using FTP software or any editor your server console provides.

    #1964277
    Philippe

    All right, but I am pretty sure I made a mistake when modifying the code. I never had a nonce_failure before. So, please, can you tell me which lines I could delete safely from within Theme/Editor/functions.php? This will help me know if anything at all can be modified there, from now on, without getting a nonce_failure. Again, I want to get rid of the code for the functionality preventing certain categories from appearing on the homepage within what is below. Thank you for replying back with the corrected code.

    <?php
    /**
    * GeneratePress child theme functions and definitions.
    *
    * Add your custom PHP in this file.
    * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
    */

    function generatepress_child_enqueue_scripts() {
    if ( is_rtl() ) {
    wp_enqueue_style( ‘generatepress-rtl’, trailingslashit( get_template_directory_uri() ) . ‘rtl.css’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘generatepress_child_enqueue_scripts’, 100 );
    add_filter(‘pre_get_posts’, ‘excludeCat’);
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set(‘cat’, ‘-43, -44’);
    }
    return $query;
    }

    add_action( ‘after_setup_theme’, ‘tu_category_specific_post_navigation’ );
    function tu_category_specific_post_navigation() {
    add_filter( ‘generate_category_post_navigation’, ‘__return_true’ );
    }

    #1964295
    David
    Staff
    Customer Support

    I can’t see any obvious errors in any of the code, but i cannot see the formatting. When you paste code in the forum, you should highlight it and click the code button – this will preserve its formatting.

    The code you need to remove is this:

    add_filter(‘pre_get_posts’, ‘excludeCat’);
    function excludeCat($query) {
    if ( $query->is_home ) {
    $query->set(‘cat’, ‘-43, -44’);
    }
    return $query;
    }
    #1964580
    Philippe

    Nice. Thank you.

    #1964583
    David
    Staff
    Customer Support

    Glad to be of help

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.