• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Allow HTML tags in text field

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Allow HTML tags in text field

This topic is: not resolved

Tagged: html tags

  • This topic has 6 replies, 2 voices, and was last updated 8 years ago by MalinD.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • May 30, 2018 at 4:59 am #220378
    MalinD
    Participant

    Hi
    I am working on a child theme for Genesis and have created some functions in the customizer.php. I now try to allow html tags to be displayed but have not succeeded. I found a lot of ideas but non of them have worked out.

    Just in this case I want the html tags to be displayed on the front page (front-page.php).

    Anyone who knows how to solve this problem?

    Regards Malin

    May 30, 2018 at 8:34 pm #220404
    Brad Dalton
    Participant

    Specifically, where on the front page?

    See this question.


    Tutorials for StudioPress Themes.

    May 31, 2018 at 12:45 am #220407
    MalinD
    Participant

    In the header I have a background image with a headline, text and a button.
    I would like to be able to add a breakline (<br>) and other tags in the text and headline.
    But this are ignored/disappearing when saving, so I belive that I have to add some code in the customizer.php to prevent that. I am not sure... Maybe something in the code at the front-page.php as well.

    May 31, 2018 at 12:56 am #220408
    Brad Dalton
    Participant

    I assume you mean the site header? You can use this code to filter the site title and add HTML tags https://my.studiopress.com/documentation/snippets/header/modify-the-header-url/

    You could also use the genesis_header hook or a filter hook for the header image.


    Tutorials for StudioPress Themes.

    May 31, 2018 at 1:24 am #220409
    MalinD
    Participant

    That was an interesting article, I will save this for later! Thank you
    I am sorry, but I think I have explained the problem porly... I don't think I can use this for my problem.

    In customizer.php I have added some sections, settings and controls. In this case I created a few text fields that the user could fill in to display the text and headline (Appearance/Customize/Header Section).

    When filling in this text field the tags are disappearing when saving.
    So what I have to do it allow html tags in the text field and to display them on the front page (or other places)

    May 31, 2018 at 4:26 am #220416
    Brad Dalton
    Participant

    If you look in the Academy Pro customize.php file you'll find the code which allows HTML tags for the top banner.

    // Top banner section.
    	$wp_customize->add_section( 'academy-top-banner-settings', array(
    		'description'     => sprintf( '%s<p>%s</p>', __( 'Modify the settings for the top banner section.', 'academy-pro' ), __( 'Each time the customizer is opened, the top banner will be displayed in the live preview so you can easily customize the content.', 'academy-pro' ) ),
    		'title'           => __( 'Top Banner Settings', 'academy-pro' ),
    		'panel'           => 'academy-settings',
    	) );
    
    	// Top banner visibility.
    	$wp_customize->add_setting( 'academy-top-banner-visibility', array(
    		'default'           => 1,
    		'sanitize_callback' => 'absint'
    	) );
    
    	$wp_customize->add_control( 'academy-top-banner-visibility', array(
    		'description' => __( 'Check the box to display a dismissible banner at the top of all pages.', 'academy-pro' ),
    		'label'       => __( 'Show Top Banner?', 'academy-pro' ),
    		'section'     => 'academy-top-banner-settings',
    		'settings'    => 'academy-top-banner-visibility',
    		'type'        => 'checkbox',
    	) );
    
    	// Hero banner text.
    	$wp_customize->add_setting( 'academy-top-banner-text', array(
    		'default'   => academy_get_default_top_banner_text(),
    		'sanitize_callback' => 'wp_kses_post',
    		'transport' => isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh',
    	) );
    
    	$wp_customize->add_control( 'academy-top-banner-text', array(
    		'description' => __( 'Change the text for the dismissible banner (allows HTML).', 'academy-pro' ),
    		'label'       => __( 'Top Banner Text', 'academy-pro' ),
    		'section'     => 'academy-top-banner-settings',
    		'settings'    => 'academy-top-banner-text',
    		'type'        => 'textarea',
    	) );
    
    	if ( isset( $wp_customize->selective_refresh ) ) {
    		$wp_customize->selective_refresh->add_partial( 'academy-top-banner-text', array(
    			'selector' => '.academy-top-banner',
    			'settings' => array( 'academy-top-banner-text' ),
    			'render_callback' => function() {
    				return get_theme_mod( 'academy-top-banner-text' );
    			}
    		) );
    	}
    

    And then output like this :

    add_action( 'genesis_before', 'academy_do_top_banner' );
    
    function academy_do_top_banner() {
    
    if ( get_theme_mod( 'academy-top-banner-visibility', true ) ) {
    
    printf( '<div class="academy-top-banner">%s</div>', get_theme_mod( 'academy-top-banner-text', academy_get_default_top_banner_text() ) );
    
    	}
    
    }
    

    Tutorials for StudioPress Themes.

    May 31, 2018 at 6:19 am #220419
    MalinD
    Participant

    Hi and a big big thank you!!
    It was the callback function in customizer.php that did the trick, I already had get_theme_mod in the front-page-file.

    Now it works like a charm!
    Thank you for taking your time and for solving this 🙂

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble