Contextual menu on posts?

  • abellerby

    #49704

    Hi,

    I have a Gallery page in the website’s News & Dates section. The page has a shortcode which displays a list of posts by category. I would like the posts to look as though they are still in the same section and have the News & Dates menu in the sidebar. In V1 I used Navigation Menus and Dynamic Widgets to control which pages they displayed on – it was a bit of a pain! I also added code to highlight the posts linked from the Gallery page in the dropdown menu so it looked as though they were in the same section.

    Is there any way to do this?

    Website is http://www.stmichaels.herts.sch.uk – go to News & Dates > Gallery

    Admin

    Syahir Hakim

    #49716

    I don’t think there is no ready-made solution for this. Looking at your site, you already have the widget in the sidebar that lists the posts in that category. Is this what you ment by using the Navigation Menus and Dynamic Widgets?

    abellerby

    #49723

    Thanks for your reply. Apologies… I managed to produce some code to display the contextual menu (News & Dates on the sidebar) on my Gallery posts and this is what you are looking at – which is a bit confusing. When I posted, the News & Dates menu was not displaying.

    To achieve this I slightly changed the code in the graphene_page_navigation function (in loop.php) and added it to my child theme’s functions.php so that it worked for pages as well as posts and manually set the $parent and $current variables for the Gallery posts.

    	$current_post = get_post($current);
    	$category=get_the_category($current);
    	if (($current_post->post_type=='post') && ($category[0]->name=='gallery')) {
    		/* Custom code for News & Dates section - parent page=27. This displays the News & Dates contextual menu on single post pages with category 'gallery' */
    		$parent = 27;
    		$current = 2936; /* ID of Gallery page */
    	}	
    	$args = array(
    		'post_type'			=> array( 'page', 'post' ),
    		'posts_per_page'	=> -1,
    		'post_parent'		=> $parent,
    		'orderby'			=> 'menu_order title',
    		'order'				=> 'ASC'
    	);
    

    It works, but I’m concerned about keeping it future update proof!

    On the subject of the contextual menu – on the child page listings, is there a way to display no image unless there is a featured image set? It doesn’t always work to display the first image on the page.

    Thanks

    Admin

    Syahir Hakim

    #49728

    Since you’ve added the code into your child theme, the modification should be preserved even after theme update.

    For the image, the easiest method is to hide it using CSS. Try adding this code to your Custom CSS option:

    .child-pages-wrap .attachment-thumbnail {
    	height: 0
    }
    .child-pages-wrap .wp-post-image {
    	height: auto
    }
    

    abellerby

    #49730

    Many thanks… it works perfectly!

    I understand that my modification will be preserved – but are you likely to be changing the graphene_page_navigation function? Presumably I will miss out if this is improved as I won’t be using the latest version?

    By the way, I have ‘Notify me of follow-up replies via email’ checked but am getting no notifications – hence my slow response to your first reply…

    abellerby

    #49732

    Sorry – one more question. Is there any way to force a custom image size (eg gallery-thumbnail which I have set up in my child theme’s functions.php) to be displayed as the thumbnail – without changing the main thumbnail size in Media Settings or adding a width/padding to your custom CSS above? I think the standard thumbnail size is a bit big…

    Admin

    Syahir Hakim

    #49734

    I understand that my modification will be preserved – but are you likely to be changing the graphene_page_navigation function? Presumably I will miss out if this is improved as I won’t be using the latest version?

    If there is any change to this specific function, it is likely to be frequent. You will need to update your custom code when that happens.

    By the way, I have ‘Notify me of follow-up replies via email’ checked but am getting no notifications – hence my slow response to your first reply…

    Try checking in your spam folder just in case it’s been falsely classified as potential spam.

    Is there any way to force a custom image size (eg gallery-thumbnail which I have set up in my child theme’s functions.php) to be displayed as the thumbnail

    Technically you can, but you’ll likely need to hook into several different Graphene and WordPress functions. Any reason against simply changing the main thumbnail size?

    abellerby

    #49736

    Many thanks again…

    What’s the best way to check if the code for graphene_page_navigation has been updated? – is there a way? Graphene is the best theme I have found for doing school websites because it’s so easy to customise – and I have about 60 sites on the go! – though they won’t all need this feature. I’m already having to apply updates individually because some are still using V1.

    Sorry – I should have thought about looking in spam but I hardly get any emails in there that shouldn’t be – I’ve found them all.

    I’m already using the main thumbnail size for photo galleries. I suppose I could create another thumbnail size for these but I would then have to change the default seting for the gallery photo size! For the time being I’ve just put some padding round the image which seems to do the trick.

    Admin

    Syahir Hakim

    #49737

    What’s the best way to check if the code for graphene_page_navigation has been updated? – is there a way?

    Unfortunately, not really. But you do not need to always have the latest code for that function. As long as nothing breaks, and it’s working as you intended, you can leave it as is.

    abellerby

    #49738

    Thanks… very impressed with the theme in general & your swift response to queries.

Viewing 10 posts - 1 through 10 (of 10 total)

  • You must be logged in to reply to this topic.