WordPress.org

Ready to get started?Download WordPress

Forums

How to make MainWrapper not show on specific page (15 posts)

  1. kubestudio
    Member
    Posted 1 year ago #

    Hi im working on a site, and it has a main wrapper for content wich shows in every other page.

    Pages and galleries are related to templates and the ones i want to change are on a specific PHP wich code is :

    <?php 
    
    get_header(); 
    
    $gallery_id = (get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true) == "") ? null : get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true);
    $gallery_columns = (get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true) == "") ? 3 : get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true);
    
    $heading_text = (get_post_meta($post->ID, THEME_METABOX . "heading_text", true) == "") ? get_the_title() : get_post_meta($post->ID, THEME_METABOX . "heading_text", true);
    ?>
    
    <!-- start mainWrapper -->
    <div id="mainWrapper">
    
    </div>
    <!-- end mainWrapper -->
    
    <?php get_template_part('templates/sidewrapper'); ?>

    I reduced the content of the wrapper to nothing, but i want to remove aswell the box containing the wrapper.

    It would be great if the wrapper was not loading on that specific page or if i can reduce its size to 0px but only on this page..

    As i need the content in the other pages, as contact, blog, etc..

    is that possible? Can anyone point me out on the exact code to replace it?

    If i just delete the

    <!-- start mainWrapper -->
    <div id="mainWrapper">
    
    </div>
    <!-- end mainWrapper -->

    it kills it in every other page.

    Thanks a million

  2. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    You could hide the content with CSS, or would you prefer PHP?

  3. kubestudio
    Member
    Posted 1 year ago #

    i think its easier for me in PHP as i could just edit that code i pasted?

    if you give me a step by step guide i don't mind!

    thanks a lot for taking effort on this

  4. kubestudio
    Member
    Posted 1 year ago #

    duplicated

  5. kubestudio
    Member
    Posted 1 year ago #

    triplicated :P

  6. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    Could you try the is_page() function in a conditional statement around your HTML?
    E.g

    <?php
    if ( is_page( $page_id ) ) {
     //display nothing for that one page
    }
    //otherwise display the HTML
    else {
    ?>
    <!-- start mainWrapper -->
    <div id="mainWrapper">
    
    </div>
    <!-- end mainWrapper -->
    <?php
    }
    ?>
  7. kubestudio
    Member
    Posted 1 year ago #

    $page_id should i put the number there?

    i mean $61 or $page_id=61 or how?

    Actually the portfolios are not pages, so the url is /?portfolio=sports

    shall i change the $page_id for $portfolio=sports ?

    thanks again

  8. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    The function's reference should answer these questions, but do respond if they don't.

  9. kubestudio
    Member
    Posted 1 year ago #

    just to try to clarify:

    The theme has different php files, and when you make a new page you assign one of those files.. Contact, blog, portfolio, etc...

    the portfolio"pages" answer to the file page-portfolio.php

    This is the code of that page:

    <?php
    /**
    Template Name: Portfolio
    */
    
    get_header(); ?>
    
    <?php
    $gallery_id = (get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true) == "") ? null : get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true);
    $gallery_columns = (get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true) == "") ? 3 : get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true);
    
    $heading_text = (get_post_meta($post->ID, THEME_METABOX . "heading_text", true) == "") ? get_the_title() : get_post_meta($post->ID, THEME_METABOX . "heading_text", true);
    ?>
    
    <!--start mainWrapper-->
    <div id="mainWrapper">
    	<?php if (have_posts()) : ?>
    		<h1 id="pageHeading"><?php echo $heading_text;?></h1>
    		<!--start content-->
    		<div id="content">
    
    		<?php get_template_part('templates/categories', 'portfolio'); ?>
    
    		<?php while (have_posts()) : the_post();  ?>
    
    			<?php the_content(); ?>
    
    		<?php endwhile;
    
    		if ( !post_password_required() ) :
    
    				comments_template(); 
    
    		endif;
    
    		?>
    
    		</div>
    		<!-- end content -->
    
    	<?php endif; ?>
    </div>			
    
    <?php get_template_part('templates/sidewrapper', 'portfolio'); ?>
    
    <?php get_footer(); ?>

    but there is another php file : single-portfolio.php that controls the created portfolios wich i think are wordpress galleries

    And this is the code of this one :

    <?php 
    
    get_header(); 
    
    $gallery_id = (get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true) == "") ? null : get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true);
    $gallery_columns = (get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true) == "") ? 3 : get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true);
    
    $heading_text = (get_post_meta($post->ID, THEME_METABOX . "heading_text", true) == "") ? get_the_title() : get_post_meta($post->ID, THEME_METABOX . "heading_text", true);
    ?>
    
    <!-- start mainWrapper -->
    <div id="mainWrapper">
    	<h1 id="pageHeading"><?php echo $heading_text;?></h1>
    	<!-- start content -->
    	<div id="content">
    		<!--start single post-->
    		<div id="singlePost">
    			<!-- start post -->
    			<div <?php post_class("last"); ?>>
    			<?php 
    
    			if (have_posts()) : while (have_posts()) : the_post();
    
    			$image_url_big = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
    
    			?>
    
    			<div class="postContent">
    
    				<?php //get_template_part('templates/entrymeta'); ?>
    
    				<?php 
    
    				the_content(); 
    
    				?>   
    
    			</div>
    
    			<?php 
    
    			endwhile; endif;
    			?>
    
    			<?php
    			if ( !post_password_required() ) :
    
    				comments_template();
    			endif;
    			?>
    			</div>
    			<!-- end post -->
    		</div>
    		<!-- end single post-->
    	</div>
    	<!-- end content -->
    </div>
    <!-- end mainWrapper -->
    
    <?php get_template_part('templates/sidewrapper'); ?>
    
    <?php get_footer(); ?>

    i tryed adding your code in both and ended on a error page from the browser when clicking the button that goes to that page.

    Still not sure if the mistake may be for how i introduced the code,

    Can you put the code in with a page id 61? that way i will see how to put in the page id.

    And what about the portfolios that have no page id number but something like that : /?portfolio=sports??

    thanks

  10. kubestudio
    Member
    Posted 1 year ago #

    sorry we crossing posts.. i will try again with the help from the link you provided..

    thanks a ton really appreciate your time

  11. kubestudio
    Member
    Posted 1 year ago #

    Ok after including the code right in the page :

    <?php
    /**
    Template Name: Portfolio
    */
    
    get_header(); ?>
    
    <?php
    $gallery_id = (get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true) == "") ? null : get_post_meta($post->ID, THEME_METABOX . 'gallery_id', true);
    $gallery_columns = (get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true) == "") ? 3 : get_post_meta($post->ID, THEME_METABOX . 'gallery_columns', true);
    
    $heading_text = (get_post_meta($post->ID, THEME_METABOX . "heading_text", true) == "") ? get_the_title() : get_post_meta($post->ID, THEME_METABOX . "heading_text", true);
    ?>
    
    <?php
    if ( is_page(61) ) {
     //display nothing for that one page
    }
    //otherwise display the HTML
    else {
    ?>
    <!-- start mainWrapper -->
    <div id="mainWrapper">
    
    </div>
    <!-- end mainWrapper -->
    <?php
    }
    ?>
    
    <!--start mainWrapper-->
    <div id="mainWrapper">
    	<?php if (have_posts()) : ?>
    		<h1 id="pageHeading"><?php echo $heading_text;?></h1>
    		<!--start content-->
    		<div id="content">
    
    		<?php get_template_part('templates/categories', 'portfolio'); ?>
    
    		<?php while (have_posts()) : the_post();  ?>
    
    			<?php the_content(); ?>
    
    		<?php endwhile;
    
    		if ( !post_password_required() ) :
    
    				comments_template(); 
    
    		endif;
    
    		?>
    
    		</div>
    		<!-- end content -->
    
    	<?php endif; ?>
    </div>			
    
    <?php get_template_part('templates/sidewrapper', 'portfolio'); ?>
    
    <?php get_footer(); ?>

    Its funny because now page 61 is normal and page 69 is showing no content but the mainWrapper still shows, empty, but stills there.

    Maybe its easier if i specify on the style.css that the width of #mainWrapper is 0px on an array of specific pages? ( portfolio ones )

    It will be easier to me if i could set up that to affect the /?portfolio=sports type instead of pages only...

    thanks

  12. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 1 year ago #

    If you're going with CSS, forum volunteers will require a link to your website & more information on which pages should/shouldn't display the HTML.

  13. kubestudio
    Member
    Posted 1 year ago #

    i dont mind how to do it, css or not, if you think we can work it out on php im happy to do it!

    page is http://kubestudio.com/web/wordpress/

    obviusly half way build ( it has music on start so be carefull with your speakers :P )

    then i want it to show in every page but in the submenus of portfolio button. Specifically it would be perfect if it doesnt show on :

    http://kubestudio.com/web/wordpress/?portfolio=sports

    And there will be more of this.. 4 or 5 wich will be

    http://kubestudio.com/web/wordpress/?portfolio=portraits
    http://kubestudio.com/web/wordpress/?portfolio=food
    etc...

    thanks!

  14. kubestudio
    Member
    Posted 1 year ago #

    anyone can give a hand?

    thanks

  15. kubestudio
    Member
    Posted 1 year ago #

    i keep trying and can't get it to work...

    What keeps pissing me off is that on the home page : Index.php The main wrapper is loaded ( view-source shows it ) but its not showing on the page, so somehow the page is identifying that is the home page and actually hiding it, not only the mainwrapper but also the sidewrapper.

    In the case of the pages i want to modify i need the sidewrapper to show but not the main wrapper.

    i can't find anywhere where it tells the home to hide those wrappers, any idea where it may be? Js files?

    if i can find it i guess i will be able to add other exceptions alike...

    thanks for the help

Topic Closed

This topic has been closed to new replies.

About this Topic