- This topic has 11 replies, 2 voices, and was last updated 4 years ago by
David.
-
AuthorPosts
-
October 15, 2021 at 3:01 am #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;}
October 15, 2021 at 3:08 am #1964127David
StaffCustomer SupportHi there,
where are you getting the
nonce_failure
– is it in the Theme Editor ?October 15, 2021 at 4:36 am #1964201Philippe
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’ );
}October 15, 2021 at 4:44 am #1964206David
StaffCustomer SupportLog 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.
October 15, 2021 at 4:48 am #1964209Philippe
Ok. Should I do that right now, before modifying the script I gave you?
October 15, 2021 at 5:17 am #1964229David
StaffCustomer SupportYes 🙂
October 15, 2021 at 5:28 am #1964243Philippe
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?
October 15, 2021 at 5:50 am #1964262David
StaffCustomer SupportIf 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.
October 15, 2021 at 6:12 am #1964277Philippe
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’ );
}October 15, 2021 at 6:28 am #1964295David
StaffCustomer SupportI 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; }
October 15, 2021 at 8:16 am #1964580Philippe
Nice. Thank you.
October 15, 2021 at 8:18 am #1964583David
StaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.