18 replies [Last post]
jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

in the template for wordpress im trying i can't get it to do what i want.

the site is : http://kubestudio.com/web/wordpress

when you click the 2nd button portfolio a sub menu opens, and what i want is that on those sub menus the "MainWrapper" is 0px wide instead of the 500 or whatever of the other pages.

Now those sub-menus ( the sports one for example ) Answer to a file called : single-portfolio.php

with this code:

<?php 
 
get_header(2); 
 
$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 changing that PHP to not load the MainWrapper but can't get it to work, so im thinking on an alternative way changing the style of this specific page.

Now i guess this page gets the Style from the Get_header , so i thought about creating a new header that calls a new style.css ( style2.css for example ) and in this style2.css i will change the width of the Mainwrapper wich works because i tried on the style.css

Now how do i do this?

i mean getting the single-portfolio.php to load style2.css instead of style.css ?

thanks a lot!

i have another post open to try to correct the issue with php but not finding a solution so maybe CSS works easier.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Brief answer: WP provides a

Brief answer: WP provides a complex series of dynamic classes applied to various objects like menus and on other elements depending on current 'Actions' it's those that usually provide you with the hooks you need to apply styles that may need to be different from a primary set.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Hi Hugo, thanks for answering

Hi Hugo,

thanks for answering but i didnt understand anything Sad

im not a programer, im just able to change my own templates now and then, and im adapting this one to my need and this is the only thing i can't manage to get to work..

i usually google my issue and after reading a few threads i find what i need to do and it works.. but this time i tryed many things and can't get it to work..

my first try was to avoid that specific page of loading that part of the code, but obviusly it did not work so someone recomended me to try to change with CSS... and i tryed to make a 2nd style.css wich contain the values i want for this specific page, then a 2nd header to load this css instead of the main style.css ... but can't figure out how to tell the header what file to load instead of style.css and last thing on my plan was to make the php of this specific page to load header 2 instead of header.php but did not manage to get this to work either..

can you give me a more detailed hand?

thanks a lot.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

WP always adds classes based

WP always adds classes based on the action that is being imvocked, page called etc always check carefully what classes are being generated on specific elements; in this instance look at the body element and the classes on that you will see many one of which will be along the lines of 'single-portfolio'as this is on a top level element it can act as a parent selector so any ruleset selectors prefixed with body.single-portfolio will be applying their rules only when on this page thus you can apply a new set of rules based on this selector:

If you had #content {width: 500px;} you could now follow that ruleset with body.single-portfolio #content{width: auto;} which re-writes the content width only for that page view.

Also it's important to understand the WP template hierarchy as explained in the WP Codex (docs):

'single.php' is responsible for rendering the post single view or full post entry in WP for single.php or page.php you may create copies of these files and add to the file name as in page-about.php now when you create a new page with the title and slug 'about' WP will look to se if the file exits 'page-about.php' only if it doesn't find one will it fall back to using page.php the default file, in this way you can add custom content, php, markup to these files in your case you could add or remove sidebar regions re-factor the markup or add a specific class to whatever elements available for styling on.

So what you do not want to be doing is creating a new style file especialy when talking about style.css as this is in affect a system file that WP needs to identify and initialise theme paramaters.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Ok i understand the concept

Ok i understand the concept but not sure how to apply this...

so what you saying is that on the styles.css where this content appears

/*----------------------------
	iii. main content 
	-----------------------------*/
 
	/*Main wrapper*/
	#mainWrapper { width:500px; position:absolute; height:auto; min-height:100%; left:260px; top:0;  display:block; overflow:hidden;}	
 
	#mainWrapper #pageHeading {margin:40px 0 40px 30px; height:auto; display:block; text-align: left; }
	#mainWrapper #content{width:420px; float:left; padding:0 40px 70px; height:100%;}
	.page_id=69 #mainWrapper { width:0px; }

i should add:

single-portfolio #mainWrapper { width:0px; position:absolute; height:auto; min-height:100%; left:260px; top:0;  display:block; overflow:hidden;}	
 
	#mainWrapper #pageHeading {margin:40px 0 40px 30px; height:auto; display:block; text-align: left; }
	#mainWrapper #content{width:420px; float:left; padding:0 40px 70px; height:100%;}
	.page_id=69 #mainWrapper { width:0px; }

underneath?

it doesnt works as it is so i guess my code is wrong? can you write down the code i need to add to make sure that new style applies to the single-portfolio.php template?

Thanks a milion

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Ok i understand the concept

Ok i understand the concept but not sure how to apply this...

so what you saying is that on the styles.css where this content appears

/*----------------------------
	iii. main content 
	-----------------------------*/
 
	/*Main wrapper*/
	#mainWrapper { width:500px; position:absolute; height:auto; min-height:100%; left:260px; top:0;  display:block; overflow:hidden;}	
 
	#mainWrapper #pageHeading {margin:40px 0 40px 30px; height:auto; display:block; text-align: left; }
	#mainWrapper #content{width:420px; float:left; padding:0 40px 70px; height:100%;}
	.page_id=69 #mainWrapper { width:0px; }

i should add:

single-portfolio #mainWrapper { width:0px; position:absolute; height:auto; min-height:100%; left:260px; top:0;  display:block; overflow:hidden;}	
 
	#mainWrapper #pageHeading {margin:40px 0 40px 30px; height:auto; display:block; text-align: left; }
	#mainWrapper #content{width:420px; float:left; padding:0 40px 70px; height:100%;}
	.page_id=69 #mainWrapper { width:0px; }

underneath?

it doesnt works as it is so i guess my code is wrong? can you write down the code i need to add to make sure that new style applies to the single-portfolio.php template?

Thanks a milion

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

No, look at the body element

No, look at the body element in your view source function of your browser, look for the class that has been added to body when on this page that is the class that you need 'page_id=69' will not be the class for that page.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Right ... so <?php

Right ...

so

<?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(); ?>

This is the template that affects the page i want to remove the menu, and i don't see any body class there...

can you point out what code to insert in this page to make it do what i want?

thanks

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

That is not 'Source View' a

That is not 'Source View' a class can only be added after a server page request has been served, that means browser sends request to server for a page, server processes all the necessary scripts it finds and sends the page to browser for rendering. all those little bits of php in that 'file' are processed by the browser it adds any instructions they give to the existing markup in the file and forms the final page that is sent on it's that stage of processing that WP works out what page request is being served and adds the appropriate classes, and those body classes are in header.php the file that must be included on all page views <body <?php body_class() ?>> not the one you show.

Study the source view of your browser that will show you how the function `body_class()` has been expanded and what array of values it held, body will now have a class with multiple tokens in it e.g:
<body class="single-item groups logged-in group-home home js customize-support">

Once you id the class that refers to your unique page that is the one to use in your styles as a parent to your #content or whatever ruleset needs re-setting.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

I think the problem is that

I think the problem is that my theme uses something different and has no body class... not sure how to explain.

in my source view there is no <body class

not sure if the fact that it loads using Ajax makes any difference... i honestly have no idea.

isnt it possible to look for a alternate route as i said on the very begining? using a different style.css and making another header and finally doing the page load the 2nd header wich is under the 2nd style.css ?

im sure it can't be so complicated but can't find the solution anywhere

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

It's a bad theme then, there

It's a bad theme then, there are many themes mostly bad sadly, it's a skill to be able to recognize ones that are built to WP standards and observe certain rules no theme should be missing body_class() there's no reason as you can add your own classes in via your own function which you add as a filter to the WP function before it's output.

I can't really advise on the route you are wanting to take as it doesn't sound plausible or feesable, there will be an approach but quite what that is is hard to see without knowing the files and exact issue.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

This is not the sort of theme

This is not the sort of theme I can help with much due to the manner in which it's built but I will give you a quick and dirty workaround.

that page is loaded via a url query string so you can check on it like so:

<?php
if( isset($_REQUEST['portfolio']) && !empty( $_REQUEST['portfolio'] ) ):
$this_page = $_REQUEST['portfolio']; // gets the query string
// create a class to add to the body element
  switch($this_page) {
  case 'sports':
   body_class = 'class="sports"';
  break;
  case 'some_other_string':
   $body_class = 'class="some-string"';
  break;
  default:
   $body_class = '';
  }
 
?>

You can then add to the body tag:
<body id="" <?php echo $body_class; ?> >

You could then wrap the sidebar thing / element in a check to see if body_class was set and if not it wouldn't render th html inside the check:

<?php if (!$body_class) : ?>
<div id=sidebar-thingy">
</div>
<?php endif; ?>

I hesitate to provide this though as it's firstly untested code so do not run on a production install and secondly it's not an approach I would take, there are always better approaches but those take time to run up and test.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Hi hugo ! Really appreciate

Hi hugo !

Really appreciate the time you taking to help me, and i hope this work arround does the trick.

But i don't understand where im supposed to do those changes!

in what php files should i write them?

thanks again

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

it would need to go in the

it would need to go in the file that holds the body tag, header.php. You then have a new class that you can overwrite the width and you can use the body_class variable as a check to remove the markup if necessary in the template file.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Im trying this hugo but seems

Im trying this hugo but seems that some javascript is overwriting any changes i do and due to that not working.

i just can't understand why in the home page view source, mainwrapper and sidewrapper are loaded ( they appear on the source code ) but they don't show on the page...

i would like to do the same thing but just with the mainwrapper in those specific pages...

may it be some Javascript to make them not show on the home page even if they appear in the source code with no special attributes?

is it possible to add anything on the

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

of the page i want to change that may hide this mainwrapper? i saw that on the home page:

<noscript>
	<style type="text/css">
	#wrapper {display:none;}
	</style>
  	<div id="noscript">
  		<h1>Please enable javascript</h1>
  		<p>It appears that your web browser does not support JavaScript, or you have temporarily disabled scripting. Either way, this site won't work without it. Please consult your web browser's documentation or IT administrator to enable javascript.
  	</div>
</noscript>

wich i understand is the way the site tells someone that needs javascript, but it has this {dispaly:none} could i use something like that for the mainwrapper of the other page?

thanks again..

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 15 hours 49 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Arrgh!

Going completely off-topic: Any developer who makes a page unusable because the user doesn't support javascript or flash or images or whatever, is an idiot. He doesn't know his boot from the crapper, which may explain why he stepped in it. That's my story and I'm sticking with it. Angry

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

after lot lot lot of time

after lot lot lot of time wasting on this im about to give up Sad

i found out the source of the style comes from the action of calling the wp_head in the header, this calls for something ( i think is functions.php ) and there is a link rel wich specifies the css to use.

still can't work out how to tell him tht for a specific page loads a different one.
i managed to make it work with some hacking, creating a 2nd header blablabla.. but then if you loaded directly the portfolio it will load the whle page without mainwrapper, and if you loaded any other page first it will load it with main wraper

my take is that the ajax loads once the style, and sticks with it for the rest of the session, so that may make it impossible to do what i want.

im gonna go another route and do external galleries unless someone has a better idea.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 40 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

functions.php is a general

functions.php is a general file that is called by WP 'init' it holds theme functions and any other functions that are required to be initialised it's a necessary file in many respects.

One thing I was forgetting is that nearly all WP functions take params thus get_header() or get_footer() etc will take a string where the string equals a named file so you can do get_header('portfolio') and that would look for a file named 'header-portfolio.php' thus you can call different headers for different circumstances however this doesn't really help you as you still need a lot of knowledge in WP functions and operation to be able to make changes, however it gives direct access to the body tag so you could place a class token in a hardcoded fashion yet again however it's clear from that file at start that the theme is already calling a diff header so think you are stuffed on that approach.

Long and short is that you have chosen a theme that is far too complex and I'm afraid your technical skills fall far too short of what is needed to start to hack this around. Either approach the theme author ( really that is the person who should be dealing with this) to see if they can modify for you or chose another simpler theme.

I would also advise reading through bits of the codex, beginners sections on themeing are quite well written and help explain how WP themes work.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jonihdz
jonihdz's picture
Offline
newbie
Last seen: 6 years 50 weeks ago
Timezone: GMT+1
Joined: 2012-10-21
Posts: 10
Points: 11

Yes thats my conclusion

Yes thats my conclusion aswell hugo.

Thanks a lot for all the help you given me, i think im gonna stick to do new window pop up galleries instead of getting them integrated until i can maybe contact to the author or get a different theme, as he is not answering my support forum post.

thanks a milion again if i can ever help you somehow don't hesitate contacting me ( im a photographer so in that field i can help Tongue )

best