Site logo

Archived topic

nonce_failure

11 replies · Started by Philippe on October 15, 2021

Viewing posts 1–12 of 12

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;

}

Hi there,

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

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' );
}

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.

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

Yes :)

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?

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.

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' );
}

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;
}

Nice. Thank you.

Glad to be of help

This archived topic is closed to new replies.