- This topic has 16 replies, 5 voices, and was last updated 5 years, 6 months ago by David.
-
AuthorPosts
-
April 7, 2018 at 12:12 am #543518Dean
Hi Tom.
From looking at the themes general.php file, I can see that GP is setting all the widget titles to h2s.
if ( ! function_exists( 'generate_widgets_init' ) ) { add_action( 'widgets_init', 'generate_widgets_init' ); /** * Register widgetized area and update sidebar with default widgets */ function generate_widgets_init() { $widgets = array( 'sidebar-1' => __( 'Right Sidebar', 'generatepress' ), 'sidebar-2' => __( 'Left Sidebar', 'generatepress' ), 'header' => __( 'Header', 'generatepress' ), 'footer-1' => __( 'Footer Widget 1', 'generatepress' ), 'footer-2' => __( 'Footer Widget 2', 'generatepress' ), 'footer-3' => __( 'Footer Widget 3', 'generatepress' ), 'footer-4' => __( 'Footer Widget 4', 'generatepress' ), 'footer-5' => __( 'Footer Widget 5', 'generatepress' ), 'footer-bar' => __( 'Footer Bar','generatepress' ), 'top-bar' => __( 'Top Bar','generatepress' ), ); foreach ( $widgets as $id => $name ) { register_sidebar( array( 'name' => $name, 'id' => $id, 'before_widget' => '<aside id="%1$s" class="widget inner-padding %2$s">', 'after_widget' => '</aside>', 'before_title' => apply_filters( 'generate_start_widget_title', '<h2 class="widget-title">' ), 'after_title' => apply_filters( 'generate_end_widget_title', '</h2>' ), ) ); } } }
I can also see there is a filter I can use to change these to h4s, but then I saw this topic on the forum where you suggest it is like this for accessibility reasons.
https://generatepress.com/forums/topic/footer-widget-heading-h2/
This has made hesitant to change them. Could you elaborate why you think it is better to have these set to h2s, because as far as I understand for SEO reasons they should be set to h4? Looking at Yoast and others they mostly use h4s and occasionally h3.
Would appreciate if you could provide any insight, otherwise I think I will go ahead and change them to h4s
Thank you :-).
April 7, 2018 at 10:57 am #543938TomLead DeveloperLead DeveloperWhen we had our accessibility review, that was one of the things that was suggested to us to increase accessibility of the theme. I believe it’s better for screen readers.
However, if you need to switch it to an h4, I don’t think it will make your site inaccessible.
April 8, 2018 at 12:12 am #544232DeanThanks for clarifying Tom :-).
April 8, 2018 at 8:27 am #544534TomLead DeveloperLead DeveloperNo problem ๐
April 25, 2018 at 11:12 pm #560663SamiYes, the widget titles should definately be h4 instead of h2 for SEO.
I tried to make this change into my child theme folder /themes/childtheme/inc/general.php but it doesn’t work. Only when I make the change to the /themes/generatepress/inc/general.php it will apply.
So what other changes / files I need in my child theme in order it to use that particular general.php?
April 26, 2018 at 9:44 am #561167TomLead DeveloperLead DeveloperYou can use whatever element you want with these filters:
add_filter( 'generate_start_widget_title', 'tu_adjust_widget_title' ); function tu_adjust_widget_title() { return '<h4 class="widget-title">'; } add_filter( 'generate_end_widget_title', 'tu_adjust_widget_title_end' ); function tu_adjust_widget_title_end() { return '</h4>'; }
September 12, 2018 at 2:10 am #675138Patriciahi!
Where am I suposed to put this filter??? I tried in the custom CSS but it doesn’t work there (sorry i’m not a programmer). Should I put that in the sidebar.php file in my child theme??? If this is it… Where at?
Thanks
September 12, 2018 at 2:55 am #675172DavidStaffCustomer SupportSeptember 12, 2018 at 3:45 am #675227Patriciammm, so I add it in the functions.php or can I put it in “Elements” as a hook?
danke
September 12, 2018 at 3:56 am #675242PatriciaI pasted the code in the funtions.php on my child theme and it crashed the site. Also not working in “Elements”. Can you be more precise, please?
sorry to bother, thanks
September 12, 2018 at 4:01 am #675248DavidStaffCustomer Supportthats odd, can you try the Code Snippets plugin mentioned in the document link?
I can’t see an issue with the code (it Tom’s so that would be rare ๐ )September 12, 2018 at 4:15 am #675262Patriciathanks, it is working with code snippets but i’d rather not to use another pluggin (i have tons). Maybe I’m pasting the code in the wrong area of the functions.php file?
Where should it go??
<?php /** * GeneratePress. * * Please do not make any edits to this file. All edits should be done in a child theme. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } // Set our theme version. define( 'GENERATE_VERSION', '2.1.4' ); if ( ! function_exists( 'generate_setup' ) ) { add_action( 'after_setup_theme', 'generate_setup' ); /** * Sets up theme defaults and registers support for various WordPress features. * * @since 0.1 */ function generate_setup() { // Make theme available for translation. load_theme_textdomain( 'generatepress' ); // Add theme support for various features. add_theme_support( 'automatic-feed-links' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status' ) ); add_theme_support( 'woocommerce' ); add_theme_support( 'title-tag' ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'custom-logo', array( 'height' => 70, 'width' => 350, 'flex-height' => true, 'flex-width' => true, ) ); // Register primary menu. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'generatepress' ), ) ); /** * Set the content width to something large * We set a more accurate width in generate_smart_content_width() */ global $content_width; if ( ! isset( $content_width ) ) { $content_width = 1200; /* pixels */ } // This theme styles the visual editor to resemble the theme style. add_editor_style( 'css/admin/editor-style.css' ); } } /** * Get all necessary theme files */ require get_template_directory() . '/inc/theme-functions.php'; require get_template_directory() . '/inc/defaults.php'; require get_template_directory() . '/inc/class-css.php'; require get_template_directory() . '/inc/css-output.php'; require get_template_directory() . '/inc/general.php'; require get_template_directory() . '/inc/customizer.php'; require get_template_directory() . '/inc/markup.php'; require get_template_directory() . '/inc/element-classes.php'; require get_template_directory() . '/inc/typography.php'; require get_template_directory() . '/inc/plugin-compat.php'; require get_template_directory() . '/inc/migrate.php'; require get_template_directory() . '/inc/deprecated.php'; if ( is_admin() ) { require get_template_directory() . '/inc/meta-box.php'; require get_template_directory() . '/inc/dashboard.php'; } /** * Load our theme structure */ require get_template_directory() . '/inc/structure/archives.php'; require get_template_directory() . '/inc/structure/comments.php'; require get_template_directory() . '/inc/structure/featured-images.php'; require get_template_directory() . '/inc/structure/footer.php'; require get_template_directory() . '/inc/structure/header.php'; require get_template_directory() . '/inc/structure/navigation.php'; require get_template_directory() . '/inc/structure/post-meta.php'; require get_template_directory() . '/inc/structure/sidebars.php';
September 12, 2018 at 4:25 am #675265DavidStaffCustomer SupportSo is that you’re child Theme function file? As it looks like a copy of the parent Theme function?
September 12, 2018 at 4:30 am #675267PatriciaYes, i duplicated the parent and pasted the code at the end.
In other php files such as “comments.php” i also clonated the file to the child theme and made the changes and additions on the child comments.php clone
Am I doing it wrong? How is this supposed to work?
thanks (and sorry, lol)
September 12, 2018 at 4:48 am #675275DavidStaffCustomer Supporthaha – so the template files such as comments.php are ok to copy. The child theme function should be blank to start with, you can get a starter one from the links provided here, and should only contain your custom functions, not duplicates of any parent function.
-
AuthorPosts
- You must be logged in to reply to this topic.