• Resolved millerguide

    (@millerguide)


    Hello,
    I would like to add a WP short code, specifically [whohit]About Us[/whohit] (for a plugin), to the main, home page in Customizr. How do I do this? Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author presscustomizr

    (@nikeo)

    Hi,
    You can add it after your home page content with this snippet (to paste in your functions.php file).

    add_action('__after_loop' , 'print_my_shortcode_on_home')
    function print_my_shortcode_on_home() {
    	//apply only on home page
    	if ( ! is_home() && !is_front_page() )
    		return;
    	do_shortcode('[whohit]About Us[/whohit]' );
    }

    Find other locations to insert it here : https://www.themesandco.com/customizr/hooks-api/#global-action-hooks

    Hope this helps!

    Thread Starter millerguide

    (@millerguide)

    nikeo, thank you, but where is my home page content? All I have is the “customize” bar on the left, and the “Custom CSS” box. Where do I Actually insert this? Thanks.

    Thread Starter millerguide

    (@millerguide)

    Nikeo, I inserted that into the functions.php, and received this error message:

    Parse error: syntax error, unexpected T_FUNCTION in /home/millerfood/www/www/wp-content/themes/customizr-child/functions.php on line 60

    Theme Author presscustomizr

    (@nikeo)

    Hi,
    there was a missing semi-colon in the code.
    Here’s the correct snippet :

    add_action('__after_loop' , 'print_my_shortcode_on_home');
    function print_my_shortcode_on_home() {
    	//apply only on home page
    	if ( ! is_home() && !is_front_page() )
    		return;
    	do_shortcode('[whohit]About Us[/whohit]' );
    }

    Thread Starter millerguide

    (@millerguide)

    nikeo, thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add WP shortcode to home page.’ is closed to new replies.