• Resolved Robert

    (@robg48)


    Hey Everyone!
    I’m trying to remove the primary navigation menu from a post that shows up when a customer, who is logged in, wants to see the details in their service ticket.

    The code for the page is:

    <?php
    /**
     * The template for displaying all pages.
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site will use a
     * different template.
     *
     * @package presscore
     * @since presscore 1.0
     */
    
    // File Security Check
    if ( ! defined( 'ABSPATH' ) ) { exit; }
    
    $config = Presscore_Config::get_instance();
    $config->set('template', 'page');
    $config->base_init();
    
    get_header(); ?>
    		<?php if ( presscore_is_content_visible() ): ?>	
    
    			<div id="content" class="content" role="main">
    
    			<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    					<?php do_action('presscore_before_loop'); ?>
    
    					<?php
    					/**  * Get the ticket details content
    					*/
    					wpas_get_template_part( 'content', 'ticket' ); ?>
    
    					<?php presscore_display_share_buttons( 'page' ); ?>
    
    					<?php comments_template( '', true ); ?>
    
    				<?php endwhile; ?>
    
    			<?php else : ?>
    
    				<?php get_template_part( 'no-results', 'page' ); ?>
    
    			<?php endif; ?>
    
    			</div><!-- #content -->
    
    			<?php do_action('presscore_after_content'); ?>
    
    		<?php endif; // if content visible ?>
    
    <?php get_footer(); ?>

    I’ve seen the codex info on page removal but, not being fairly thick when it comes to editing – well, I’ve tried several variations and none worked.

    If inserting a line of code into the above will do it could tell me where it goes? I didn’t think it made all that difference…but maybe that’s my html memories ??

    Thanks!
    Rob

Viewing 11 replies - 1 through 11 (of 11 total)
  • Firstly, the primary menu should be echo-ed in the get_header() part, so header.php file would be more useful to be pasted here.

    What is the link to your site? We could remove the primary menu with CSS, such as

    .your-menu-class {
       display: none !important;
    }

    You need to substitue .your-menu-class with a proper CSS selector for the primary menu.

    Thread Starter Robert

    (@robg48)

    Thanks for the quick reply!

    I’m not sure of the semantics – but looking at it in Firebug it’s the main-nav menu.

    So changing it with CSS wouldn’t impact the menu’s availability on other pages?

    Here’s the header:

    <?php
    /**
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div class="wf-container wf-clearfix">
     *
     * @package presscore
     * @since presscore 0.1
     */
    
    // File Security Check
    if ( ! defined( 'ABSPATH' ) ) { exit; }
    
    ?><!DOCTYPE html>
    <!--[if IE 6]>
    <html id="ie6" class="ancient-ie old-ie no-js" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if IE 7]>
    <html id="ie7" class="ancient-ie old-ie no-js" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if IE 8]>
    <html id="ie8" class="old-ie no-js" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if IE 9]>
    <html id="ie9" class="old-ie9 no-js" <?php language_attributes(); ?>>
    <![endif]-->
    <!--[if !(IE 6) | !(IE 7) | !(IE 8)  ]><!-->
    <html class="no-js" <?php language_attributes(); ?>>
    <!--<![endif]-->
    <head>
    	<meta charset="<?php bloginfo( 'charset' ); ?>" />
    	<?php if ( presscore_responsive() ) : ?>
    	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    	<?php endif; // is responsive?>
    	<?php if ( dt_retina_on() ) { dt_core_detect_retina_script(); } ?>
    	<title><?php echo presscore_blog_title(); ?></title>
    	<link rel="profile" href="https://gmpg.org/xfn/11" />
    	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    	<!--[if IE]>
    	<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    	<![endif]-->
    	<style type="text/css" id="static-stylesheet"></style>
    	<?php
    	if ( ! is_preview() ) {
    
    		presscore_favicon();
    
    		echo of_get_option('general-tracking_code', '');
    
    		presscore_icons_for_handhelded_devices();
    
    	}
    
    	wp_head();
    	?>
    </head>
    
    <body <?php body_class(); ?>>
    
    <?php do_action( 'presscore_body_top' ); ?>
    
    <div id="page"<?php if ( 'boxed' == of_get_option('general-layout', 'wide') ) echo ' class="boxed"'; ?>>
    
    <?php if ( of_get_option('top_bar-show', 1) ) : ?>
    
    	<?php get_template_part( 'templates/header/top-bar', of_get_option('top_bar-content_alignment', 'side') ); ?>
    
    <?php endif; // show top bar ?>
    
    <?php if ( apply_filters( 'presscore_show_header', true ) ) : ?>
    
    	<?php get_template_part( 'templates/header/header', of_get_option( 'header-layout', 'left' ) ); ?>
    
    <?php endif; // show header ?>
    
    	<?php do_action( 'presscore_before_main_container' ); ?>
    
    	<div id="main" <?php presscore_main_container_classes(); ?>><!-- class="sidebar-none", class="sidebar-left", class="sidebar-right" -->
    
    <?php if ( presscore_is_content_visible() ): ?>
    
    		<div class="main-gradient"></div>
    
    		<div class="wf-wrap">
    			<div class="wf-container-main">
    
    				<?php do_action( 'presscore_before_content' ); ?>
    
    <?php endif; ?>

    Well, if you just put that display to none in the general css without further specific selectors for a specific page(s), it would definitely affect all of the pages:

    // Don't do this
    #main-nav {
       display: none;
    }

    What you are looking for is a special css class given for the specific page on which you want the menu to be removed on. Good thing is that proper WordPress theme uses body_class() function to output classes for the <body> tag. I can see this in your code, so only thing you need to do is add a condition that “if the page I’m currently visiting is of ID or type this and that, add a special class to the body_class() function. For example:

    [... previous code in header.php ...]
    
    		presscore_icons_for_handhelded_devices();
    
    	}
    
    	wp_head();
    	?>
    </head>
    
    $additional_classes = "";
    
    if (is_single(1)) { // '1' is ID of your specific page
         $additional_classes = 'page-no-menu'; // whatever the name
    }
    
    <body <?php body_class($additional_classes); //this is important ?>>
    
    [... the rest of the code in header.php ...]

    Now, you would put

    .page-no-menu #main-nav {
       display: none !important;
    }

    in your main css file at the end of it.

    Anytime you visit page with the ID of ‘1’, that new class would apply to the body element and your custom css would take precedence.

    Further reading if having trouble:
    setting-the-body-class-name-for-a-page
    body_class()
    Conditional Tags

    Thread Starter Robert

    (@robg48)

    Thanks for all your information and help!

    I think this is going to beyond me ??

    Part of the problem is it is not a “single page” – it’s not a page at all. If it were a page
    I could just edit that page.

    When a customer visits the site and opens a help desk ticket and then click on the ticket details it brings them to a url “technologysolutionslive.com/tickets/ticketsubjectline” –
    and I think this is fed/created directly from the db as I can’t find any posts/pages that correspond to a particular ticket.

    But whatever is going on – each time a user clicks on “ticket details” to view their ticket, it has a unique url ending with the whatever the user put in the subject line of their ticket.

    I appreciate your help but I think I’ll just leave the menu there for now…lol…it seems a little beyond me at this point – I’m just an infrastructure guy ??

    If it is WordPress, it should be some kind of Page, how else would the resulting HTML be generated? ??

    I understand that it’s not a single page. That was just an example how you can conditionally do stuff. We need to identify from where it is being generated.

    Can you give me the ticket’s page <body> as a code snippet here? Not from the code but from the generated HTML. Just that one line (<body class="bla bla" [...]>)

    Thread Starter Robert

    (@robg48)

    That’s what I always thought…lol

    There is mention of a “post-id #” but when I go into posts and search for it – nothing comes up. And, like I said, I want the menu removed from all the ticket details page – so even removing from one post, if I could find it!, I’m not sure that would do it.

    Here’s the snippet:
    `
    <body class=”single single-tickets postid-22510 logged-in admin-bar no-customize-support image-blur boxed-layout btn-ios wpb-js-composer js-comp-ver-4.3.4 vc_responsive”>’

    And, if you’d like to login as the user and see the page – and the entire page source –

    https://technologysolutionslive.com

    Login with:
    trident45
    rasker50

    Then click on the “title” of the ticket….then you’ll be in the “details” page – the page I want to remove the menu from.

    Thanks again for all your time!

    That’s what I needed! Have you noticed the class single-tickets in the <body>‘s classes? That’s very helpful. As far as I can see, that class is added to the <body> only when viewing a single ticket’s details. The only thing we need to do is to add this piece of css at the bottom of your style.css file:

    .single-tickets #main-nav {
       display: none;
    }

    Give it a try and let me know the result.

    Thread Starter Robert

    (@robg48)

    Worked perfectly!!!

    That’s great…thank you so much!

    Yes, now that I see it all I may be able to understand it better when I read about it ??

    Appreciate all your help!
    Rob

    Glad it helped you ??

    Rasto

    Thread Starter Robert

    (@robg48)

    Thanks Rasto!

    Thread Starter Robert

    (@robg48)

    Forgot to close… ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Having troubles removing a menu’ is closed to new replies.