Search Results for 'generate_logo_href'

Home Forums Search Search Results for 'generate_logo_href'

Viewing 15 results - 1 through 15 (of 98 total)
  • Author
    Search Results
  • #1188757

    Tom Lead Developer

    Typically there isn’t enough space to show both on mobile, but you can insert the logo like this:

    add_action( 'generate_inside_mobile_header_branding', function() {
        if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
            return;
        }
    
        $settings = wp_parse_args(
            get_option( 'generate_menu_plus_settings', array() ),
            generate_menu_plus_get_defaults()
        );
    
        printf(
            '<div class="site-logo mobile-header-logo">
                <a href="%1$s" title="%2$s" rel="home">
                    <img src="%3$s" alt="%4$s" />
                </a>
            </div>',
            esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    } );
    #1185641

    David Customer Support

    Try this snippet instead:

    add_filter( 'generate_logo_output', 'tu_logo_class', 10, 3 );
    function tu_logo_class( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="navigation-branding">
    			<div class="site-logo">
    				<a href="%1$s" title="%2$s" rel="home">
    					<img data-gumlet="false" data-gmlazy="false" %3$s />
    				</a>
    			</div>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
    	);
    }

    It may require some CSS for sizing – so add the code and let know.

    #1184481

    David Customer Support

    Hi there,

    try adding this PHP Snippet:

    add_filter( 'generate_navigation_logo_output', function() {
        return sprintf(
            '<div class="site-logo sticky-logo navigation-logo">
                <a href="%1$s" title="%2$s" rel="home">
                    <img data-gumlet="false" src="%3$s" alt="%4$s" />
                </a>
            </div>',
            esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            esc_url( apply_filters( 'generate_navigation_logo', $settings['sticky_menu_logo'] ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    } );
    #1172059

    Tom Lead Developer

    Hi there,

    It can’t be added to an Element, but you can target your store.

    For example:

    add_filter( 'generate_logo_href', function( $href ) {
        if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
            $href = 'URL TO YOUR STORE';
        }
    
        return $href;
    } );

    Let me know if that helps or not 🙂

    #1171832

    Sam

    Hi Leo!
    Thanks for your reply.

    This is what I have so far, I know it’s incomplete:

    if (  the_hook_name??? () ) {
    add_filter( 'generate_logo_href', 'generate_newlogo_href' );
    function generate_newlogo_href()
    { 
        return 'https://www.sementesdamor.pt/loja/';
    }
    }

    I wonder…
    can I insert the code in the element directly? In that case, what are the parameters?
    Or I’ll need to create a code snippet? In that case, what is the hook name?

    #1171727

    Leo Customer Support
    #1161994

    In reply to: H1 for homepage logo


    David Customer Support

    Hi there,

    you can try this PHP snippet to add the H1 for the homepage only:

    <?php
    add_filter( 'generate_logo_output', 'db_home_logo_htag', 10, 3 );
    function db_home_logo_htag( $output, $logo_url, $html_attr ) {
    
        if ( is_front_page() ) {
        
            printf(
    		'<div class="site-logo">
                <h1>
    			    <a href="%1$s" title="%2$s" rel="home">
    				    <img %3$s />
                    </a>
                </h1>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
        
            );
        } else {
        
            printf(
    		'<div class="site-logo">
    		    <a href="%1$s" title="%2$s" rel="home">
    			    <img %3$s />
    			</a>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
        
            );
        }
    
    }

    Then this CSS to remove the H1 styling:

    .site-logo h1 {
        margin-bottom: 0 !important;
        line-height: unset;
        font-size: 0;
    }
    #1158150

    Martin

    Here’s a different approach I found, editing only the functions.php file in the child theme folder, which is preferred so the modification wont interfere with future updates of the main theme files:

    Add this code to the functions.php file:

    // LOGGED-IN USERS : HOME URL FOR TOP LOGO/HEADER IMAGE IN GENERATE PRESS
    if ( is_user_logged_in() ) {
    // set header logo image url when logged-in
    add_filter( ‘generate_logo_href’,’generate_add_custom_logo_href’ );
    function generate_add_custom_logo_href()
    {
    return ‘https://www.yourwebsite.com/logged-in-url/’;
    }
    }

    #1157805

    Martin

    Finally I found a way to do it. I’m sharing it here in case someone in the future would like to do something similar.

    1) Create a CHILD THEME from the used theme
    2) In the Child Theme Folder:

    A) Edit functions.php, and add this code:

    // shortcode to display content for loggedout and loggedin users : shortcodes are [loggedout] [loggedin]
    add_shortcode( ‘loggedout’, ‘visitor_check_shortcode’ );
    function visitor_check_shortcode( $atts, $content = null ) {
    if ( ( !is_user_logged_in() && !is_null( $content ) ) || is_feed() )
    return do_shortcode($content);
    return ”;
    }
    add_shortcode( ‘loggedin’, ‘member_check_shortcode’ );
    function member_check_shortcode( $atts, $content = null ) {
    if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
    return do_shortcode($content);
    return ”;
    }

    B) Copy the file header.php from your theme to the child theme.
    Then edit header.php:
    Add the following in the top of the header.php file, somewhere before <body>:

    <!– CUSTOM HOME URL ON GP LOGO IMAGE IF USER IS LOGGED-IN –>
    <?php
    if ( is_user_logged_in() ) {
    add_filter( ‘generate_logo_href’,’generate_add_custom_logo_href’ );
    function generate_add_custom_logo_href()
    {
    return ‘https://www.yourwebsite.com/logged-in-url’;
    } else {
    }
    ?>
    <!– END CUSTOM HOME URL IF USER IS LOGGED-IN –>

    #1123094

    Tom Lead Developer

    It’s most likely the logo – the three lines/text aren’t images.

    The mobile header logo doesn’t have a specific class, but we can tell WPRocket not to lazy load it with a filter:

    add_filter( 'generate_mobile_header_logo_output', function( $output ) {
        if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
            return $output;
        }
    
        $settings = wp_parse_args(
            get_option( 'generate_menu_plus_settings', array() ),
            generate_menu_plus_get_defaults()
        );
    
        return sprintf(
            '<div class="site-logo mobile-header-logo">
                <a href="%1$s" title="%2$s" rel="home">
                    <img src="%3$s" data-no-lazy="1" alt="%4$s" />
                </a>
            </div>',
            esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1102526

    In reply to: Remote Hosting of Logo


    simit

    hi leo, thanks for your reply. i added the code below via the code snippets plugin. however, it doesn’t seem to be working on my site (https://sixjupiter.wpengine.com). any thoughts?

    add_filter( 'generate_logo_output', 'tu_logo_class', 10, 3 );
    function tu_logo_class( $output, $logo_url, $html_attr ) {
    	printf(
    		'<div class="site-logo MY-CUSTOM-CLASS">
    			<a href="%1$s" title="%2$s" rel="home">
    				<img src = "https://storage.googleapis.com/sjn-charts/dfx2/cfdt-s.png">
    			</a>
    		</div>',
    		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    		$html_attr
    	);
    }
    #1064488

    In reply to: HOME URL WITH JS


    Leo Customer Support

    Hi there,

    So are you trying to change where the site logo links to when clicked?

    If so you can use this filter:
    https://docs.generatepress.com/article/generate_logo_href/

    See some examples here:
    https://generatepress.com/forums/search/generate_logo_href/

    Let me know if this helps 🙂

    #1015756

    Leo

    Hi!

    I’m having the same issue with the logo link for different languages using Polylang. Unfortunately, I cannot use the easy solution posted by Adam, so I tried the function suggested by Tom. 

    I made a GP Element like this:

    add_filter( ‘generate_logo_href’, ‘tu_english_navigation_logo_url’ );
    function tu_english_navigation_logo_url( $url ) {
        if ( ! function_exists( ‘pll_current_language’ ) ) {
            return $url;
        }

        if ( ‘English’ == pll_current_language( ‘name’ ) ) {
            return ‘https://www.ruskus-patruskus.com/en/’;
        }

        return $url;
    }

    I placed it “before_logo” (I tried other locations but it doesn’t work and the code lines shows up on the pages). I marked “Execute PHP” and in Display Rules > Location I chose “Entire Site”.

    However, it’s not working. What am I doing wrong?

    Thanks in advance. 🙂

    #997548

    Tom Lead Developer

    Hi there,

    Give this a shot:

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
        $elements[] = '.sticky-navigation-logo a';
      
        return $elements;
    } );
    
    add_filter( 'generate_logo_href', function() {
        return '#top';
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    I also noticed a z-index issue on the page, you might want to add this:

    .header-wrap {
        z-index: 100;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    Hope this helps 🙂

    #988127

    Leo Customer Support

    What if we change the logo URL for posts page, all archives and single posts?

    add_filter( 'generate_logo_href', function( $url ) {
        if ( is_home() || is_archive() || is_single() ) {
            return 'URL ON POSTS PAGE';
        }
    
        return $url;
    } );

    You can find all the available conditional tags from WordPress here:
    https://codex.wordpress.org/Conditional_Tags

Viewing 15 results - 1 through 15 (of 98 total)