Okay
  Public Ticket #2560018
Custom link for logos on specific pages ??
Closed

Comments

  •  2
    gluon started the conversation

    Hi there,

    using Kalium on 4 websites, I love it.

    But I have a very important issue:

    I'd need to customize the link on the logo.

    Several pages should have a specific link to my root page, some others should have a link to another page.

    Is it possible ?

    Thanks a lot

    Julien

  • [deleted] replied

    Hi Julien,

    I can give you a code snippet to provide you ability to change the logo URL via Advanced Custom Fields plugin. Will that work for you?

    For example, only for pages you edit you can set the logo link. For blog, and other page archives that is not possible. Will this work for you?

  •  2
    gluon replied

    Hi Arlind,

    Yes, it could be nice. I didn't know we could do that with ACF plugin.

    Actually, this is not depending on type (post, page, etc) but more on specific pages.


  • [deleted] replied

    Ok great! Please provide the WP credentials and I can implement this feature in your site.

    To include your credentials click Insert Credentials button in editor toolbar. (See how)

  •  2
    gluon replied

    Hi Arlind, I'm sorry, I'm not comfortable with giving my credentials.
    Thanks, anyway.

  • [deleted] replied

    Hi Julien,

    Totally understandable.

    I've created the code to provide you the ability to change logo URL. So here is what you need to do:

    Add the following code in functions.php (end of file):

    if ( function_exists( 'acf_add_local_field_group' ) ) {
        acf_add_local_field_group( [
            'key'                   => 'group_5f7eb827c3e68',
            'title'                 => 'Logo URL',
            'fields'                => [
                [
                    'key'               => 'field_5f7eb83329440',
                    'label'             => 'Custom Logo URL',
                    'name'              => 'custom_logo_url',
                    'type'              => 'text',
                    'instructions'      => 'Leave empty to use current site address.',
                    'required'          => 0,
                    'conditional_logic' => 0,
                    'wrapper'           => [
                        'width' => '',
                        'class' => '',
                        'id'    => '',
                    ],
                    'default_value'     => '',
                    'placeholder'       => 'https://',
                    'prepend'           => '',
                    'append'            => '',
                    'maxlength'         => '',
                ],
            ],
            'location'              => [
                [
                    [
                        'param'    => 'post_type',
                        'operator' => '==',
                        'value'    => 'page',
                    ],
                ],
                [
                    [
                        'param'    => 'post_type',
                        'operator' => '==',
                        'value'    => 'post',
                    ],
                ],
                [
                    [
                        'param'    => 'post_type',
                        'operator' => '==',
                        'value'    => 'product',
                    ],
                ],
                [
                    [
                        'param'    => 'post_type',
                        'operator' => '==',
                        'value'    => 'portfolio',
                    ],
                ],
            ],
            'menu_order'            => 0,
            'position'              => 'normal',
            'style'                 => 'default',
            'label_placement'       => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen'        => '',
            'active'                => true,
            'description'           => '',
        ] );
    }
    add_filter( 'kalium_logo_url', function ( $url ) {
        if ( is_singular() && ( $custom_logo_url = kalium_get_field( 'custom_logo_url', kalium_get_queried_object_id() ) ) ) {
            if ( 0 === strpos( $custom_logo_url, 'http' ) ) {
                return $custom_logo_url;
            }
        }
        return $url;
    } );

    I've tested and it worked:

    https://d.pr/v/lZFJRp

    P.S: This was a customization question and support doesn't offer customization services as we wrote on our support homepage and on this area. I tried to help you this time though.

  •  2
    gluon replied

    Hello and thanks, 

    I understand, and it doesn't work (for instance I'd need to have THIS url link for the page ids 34 36 12 and 89, and THAT url link for the page ids 59 32 56 and 13)

    Let's close it, if it is not possible, I'll work around it.

  • [deleted] replied

    I'm sorry, I tried to help and my solution works on my end but if you are not happy with it you can hire someone to make this customization for you.

    I wish you have a great week!

    Will mark this ticket as closed from here.

  •  2
    gluon replied

    I'm happy, but it was not solving what I needed (specific pages and not specific types), as mentioned and it wasn't my intention to have something free if it is not free. I'll find a way to do it by myself.

    Thanks again.