Site logo

Archived topic

custom logo and menu for custom post types

8 replies · Started by Nikolaj on November 8, 2018

Viewing posts 1–9 of 9

dear GP,
I'm running a 'subcategory' of posts all based on a custom post types; I want to add specific logo and navigation for these posts while still using the default on all other pages and posts; Basically I want to change default logo/menu for specific posts based on specific custom post type

How to do that? which files to change? I know how to set up specific php pages in childtheme but can't seem to find where to change / delete.

Look forward to hearing from you;)

Hi there,

For the menu, you can try a plugin like this: https://wordpress.org/plugins/conditional-menus/

For the logo, you can use a function:

add_filter( 'generate_logo', function( $url ) {
    if ( is_singular( 'my-post-type' ) ) {
        $url = 'my custom post type logo URL';
    }

    return $url;
} );

Let me know if you need more info :)

thanks I'll try that;

In the current setup I'm using the following hook to show different logo's according to member status:

<?php if (current_user_can('optik_butik') AND current_user_can('deo_medlem')) : ?>
<a href="http://www.medlemsnet.dk"><img src="http://www.medlemsnet.dk/wp-content/uploads/2018/06/doHook.png" class="topLogoRB"> </a><a href="http://www.medlemsnet.dk/forsidedeo18/"><img src="http://www.medlemsnet.dk/wp-content/uploads/2018/06/deoHook.png" class="topLogoRB"> </a>

How to make a hook that only works for a seperate custompost type or 2 chosen posttypes?

You could try this:

<?php
$post_type = get_post_type();

if ( 'your-post-type' === $post_type || 'another-one' === $post_type ) : ?>

    Your HTML in here

<?php endif; ?>

hmm it doesn't seem to work?

and isn't it able within a copy of one of the theme pages example.: content-single-optikeren.php to just diable both primary and secondary menu?

I'm not sure I understand. What are the contents of your hook? Which hook are you adding it to?

It's possible to disable the menus based on conditions with some filters if that's what you're after?

dear Tom,
2 things:

1. This is the content of the hook "wp_head". It doesn't seem to work when added to the hook? :

<?php
$post_type = get_post_types();

if ( 'optikeren' === $post_type || 'jobannoncer' === $post_type ) : ?>

    <div class="test">Your HTML in here</div>

<?php endif; ?>

2. It’s possible to disable the menus based on conditions with some filters if that’s what you’re after? Sure I would like a filter that could disable the menus for the custom post type "optikeren".

1. I just updated the code above - can you give it another shot?: https://generatepress.com/forums/topic/custom-logo-and-menu-for-custom-post-types/#post-723421

wp_head isn't meant for HTML. You'll want to use the before_header hook if that's where you want the HTML.

2. Try this:

add_filter( 'generate_navigation_location', function( $location ) {
    $post_type = get_post_type();

    if ( 'optikeren' === $post_type || 'jobannoncer' === $post_type ) {
        return false;
    }

    return $location;
} );
This archived topic is closed to new replies.