Viewing 8 replies - 1 through 8 (of 8 total)
  • In this particular option will need to have individual css for each page

    One view of it: https://www.ads-software.com/support/topic/236049?replies=5

    I too am wondering how I edit my pages separately from my posts !!!

    For example, I dont want my pages to say the date it was published, because it is intended to be static.

    If I take this out of the code, it appears to take it off of everything, pages and posts alike.

    Any suggestions for advanced code access for pages so i can go in there and comment out the ‘bloggy’ features so that they dont appear in my ‘contact me’ page??

    please help.
    Thank you!!!

    <body <?php if (function_exists('body_class')) { body_class(); } ?>>

    Then do a view source on whatever page your looking to modify and you can see specific body css classes you can use.

    For example:

    <body class=”page page-id-6 page-parent page-template page-template-archive-comic-php logged-in ie”>

    This is my archive page, root level page for all the different archive pages I have. It says the page-id-6 .. so if say I wanted a specific background or background color for this page I would do:

    body .page-id-6 { background: #ccc; }

    if I wanted to hide say the title which in my css the element is div class=”pagetitle”

    .page-id-6 .pagetitle { display: none; }

    that will make that .pagetitle on that specific page, disappear.

    Notice the body classes also include if someone is logged in or not and since they are logged in I want to, I dunno make the title white /shrug

    .logged-in .pagetitle { color: #fff; }

    With body_class you can pretty much do anything to any specific page on your site just by getting a class from the body_class that is individual for just that page.

    *the IE that you see in the body class was added there by an function in my functions.php*

    add_filter('body_class','browser_body_class');
    
    function browser_body_class($classes = '') {
    	global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    
    	if($is_lynx) $classes[] = 'lynx';
    	elseif($is_gecko) $classes[] = 'gecko';
    	elseif($is_opera) $classes[] = 'opera';
    	elseif($is_NS4) $classes[] = 'ns4';
    	elseif($is_safari) $classes[] = 'safari';
    	elseif($is_chrome) $classes[] = 'chrome';
    	elseif($is_IE) $classes[] = 'ie';
    	else $classes[] = 'unknown';
    
    	if($is_iphone) $classes[] = 'iphone';
    	return $classes;
    }

    That will add the type of browser the end user is using to the body_class.. but you can also do some fun things with it as well.

    For example, If you want to say do some code that is specific for the browser type checking out your system:

    if (reset(browser_body_class()) == ‘ie’) {
    print “Only people with IE browsers will see this.\r\n”;
    }

    ^ the reset() makes the array turn into a string.

    thank you, that is very thorough!

    i understand the logic, but unfortunately i am unable to find any body class tag to tip me off as to what the page id would be…

    where should i be looking for this? after the opening body tag? in the main entry div?
    is it possible that my theme doesnt have this?

    is there any way to do something similar using the page <title> as this is only page with that title?

    thank you again!

    Yeah it’s fairly new.

    open your header.php file and find the <body> tag and add

    <?php if (function_exists(‘body_class’)) { body_class(); } ?>

    That to it. example:

    <body <?php if (function_exists(‘body_class’)) { body_class(); } ?>>

    and if your using 2.8+ of wordpress you will see the classes when you open your website and view-source

    This is great. But, unfortunately for PAGES, WordPress only shows the ancestors one level up. That is, it adds:

    page-child parent-pageid-(id)

    Would be nice if it did an “ancestor-pageid-id” or similar, no?

    yumiam

    (@yumiam)

    +1 …?
    ancestor-pageid-id would be realy nice …?

    yumiam

    (@yumiam)

    hey Klark123 …
    i’ve just find something ;
    https://www.wprecipes.com/wordpress-hack-extend-the-body_class-function

    yeah … nice

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Different theme for pages’ is closed to new replies.