Archived

This topic is now archived and is closed to further replies.

  • 0

Help on adding new body classes

Question

Posted · Report post

For a project I want to add two additional body classes. One would switch the site to a black, white, and yellow high-contrast version, and the other would show a different background image for all posts within a certain category (category-29). This is a custom taxonomy.

 

I'm struggling to get this implemented. One of the things which is throwing me is the Current Install Class Pro box within the admin panel. I have tried adding my class here on its own, as well as the class plus selectors, to no luck. Do I simply put the bodyclass and selectors in with the custom CSS?

 

Another thing which is confusing me is the difference between the WP standard

add_filter('body_class','classname');

and

add_filter('pagelines_add_bodyclass','classname');

 

Do I still need to call this in functions.php or does the Current Install Class Pro box create the filter?

 

 

Share this post


Link to post
Share on other sites

23 answers to this question

Posted · Report post

I feel as if I am repeating myself here: the issue is not the formatting of the statement, the issue is the difference between the statement and the box within the Pagelines Admin panel as shown:

 

post-29110-0-78200300-1359365873_thumb.p

Share this post


Link to post
Share on other sites

Posted · Report post

One is a filter the other is an option in the framework.

 

I'm still not sure what the issue is, I have just attempted again to add custom classes to the body and it worked again perfectly.

 

Can you provide a screenshot of what you have actually added to the Custom Class field please.

Share this post


Link to post
Share on other sites

Posted · Report post

Still trying things as basic as changing the login screen background color with a body class - body.login {background-color: #xxxxxx}; and nothing happens.
 

Now that this project has now moved from a local install onto the hosting account, can I PM you a login and password?

 

Also before you get on me about not using a child theme - trying to install the base child theme from the start turned the entire site into the white screen of death. The only way to regain any access was to delete the base child theme. I have had to edit the framework as it's provided.

Share this post


Link to post
Share on other sites

Posted · Report post

The CSS is already in use by Wordpress, so you will need to either use !important in your code to override or you could use the one of the other classes.

 

body.login-action-login {
background: red;
}

Also we do not recommend editing the core files or provide support to changes made to the core files. If you enable the Base child theme from the PageLines store and you receive a white screen, then you most likely do not have enough PHP allocated memory.

 

When you enabled the PageLines Framework Base child theme, did you receive an error?

Share this post


Link to post
Share on other sites

Posted · Report post

!Important isn't working. Overriding isn't working. I've tried. This is what I've been trying to say for a fortnight. Something is not right here. Where it comes to body classes, basic CSS which would take two seconds to do with a regular theme is somehow being prevented from working. Some element of the extensive custom taxonomies, permalink structure, or the changes to functions.php that they required is not sitting well with Pagelines.

 

There was no error message with the base child theme. This was on a fresh installation on a brand new hosting account (set up February 2013, 512mb ram) with nothing else on it. It downloads fine, but activating it kills the site. I have to FTP in and delete it to regain access to the dashboard. I increased the memory in wp-config and the white screen still happened. The only dodgy plugin I found was ActionMap (!) and disabling that didn't help.

 

At this point, I have to get this site delivered to the client in three weeks, and instead of getting it ready for testing I'm fighting with PageLines. I know you don't recommend or provide support for editing of the core files, but I am not doing it by choice. So can you just clarify whether you are willing to log in to see if you can find something that I've missed?

Share this post


Link to post
Share on other sites

Posted · Report post

HI,

 

The Body class is working for me

 

http://d.pr/i/xoAn

http://d.pr/i/H7YN

 

For different background images for specific categories, use the following as an example:

 

.category-uncategorized .page-canvas {
background: red;
}
.category-abc .page-canvas {
background: green;
}

Replace uncategorized and abc with your category names.

Share this post


Link to post
Share on other sites

Posted · Report post

Unfortunately this does not work at all.

Share this post


Link to post
Share on other sites

Posted · Report post

What isn't working, the body class examples or the category CSS example ?

 

As I have both working on my test site

Share this post


Link to post
Share on other sites

Posted · Report post

The category CSS isn't working, and everything I have tried with the body class box is ineffective as well.

 

Could this have something to do with the permalink structure we've put in to accommodate the custom taxonomies? The category base is "category".

Share this post


Link to post
Share on other sites

Posted · Report post

Can you provide me with a link to the site in question and the page in question please.

Share this post


Link to post
Share on other sites

Posted · Report post

It's still on a local installation.

Share this post


Link to post
Share on other sites

Posted · Report post

Well its difficult to diagnose the issue when its a local installation, as I have no issue using the body classes or the category class.

 

Can you add your custom CSS to our paste server and we can take a look. http://paste.pagelines.com

Share this post


Link to post
Share on other sites

Posted · Report post

There isn't any CSS to paste, seeing as I can't get something as innocuous as

.category-magazine .page-canvas {
background: #fff;
}

to work, much less the full selector (simply a background image.)

Can you explain the add_filter('pagelines_add_bodyclass','classname'); bit?

Share this post


Link to post
Share on other sites

Posted · Report post

I mentioned above that the login page is not styled by PageLines but is done so by Wordpress. If you're unable to style the Wordpress login, you will need to get assistance from the Wordpress forums.

 

Regarding your issue with the custom body class, I am not sure how to resolve your issue as I am unable to reproduce your issue. I have created several custom post types and taxonomies, with different permalink structure and all my custom CSS, including the custom body classes work.

 

Increasing the memory in Wordpress, doesn't really resolve the issue, if attempting to activate a child theme kills your site, this most likely means that you have ran out of PHP memory. To resolve the issue, you will need to ask your host to increase the value, only your host can resolve this problem.

 

Can you go into greater detail regarding your comment about the Action Map plugin please.

 

Also, if you have made changes to the core files, this may be the cause of some of your problems.

 

I recommend you contact your web host provide and ask them to increase your PHP memory and also reply with the following information please.

 

  • Provide a link to your PHPinfo, for information on how to do this, read the Wordpress article here - http://codex.wordpress.org/Finding_Server_Info
  • Add the custom CSS you're using to our pastie service - http://paste.pagelines.com/
  • Where abouts are you adding your custom css, to the customise plugin or Custom Code area in the settings ?
  • Also, can you enable PageLines debug mode - PageLines > Site Options > Advanced > 

Share this post


Link to post
Share on other sites

Posted · Report post

Try this instead:

 

#site .category-magazine .page-canvas {
background: #fff;
}

 

To add a background image, use the following:

 

#site .category-magazine .page-canvas {
background-image: url(URL To Image Goes Here);
background-repeat: ;
background-position: ;
}

For information on filters, I recommend reading the Wordpress article - http://codex.wordpress.org/Function_Reference/add_filter

 

You can find a list of actions/filters here - http://api.pagelines.com/hooks

 

Or by using the Action Map plugin available for free on the PageLines store.

 

An example of a filter can been seen here - http://www.pagelines.com/forum/topic/24711-custom-menu-class/?hl=add_filter#entry144294

Share this post


Link to post
Share on other sites

Posted · Report post

Hi there,

 

After you've fixed your other issues, if you are still looking for a solution to styling the login screen:

 

You need a function to add a separate stylesheet for the login screen alone (this function is adjusted to work for a child theme):

function my_login_stylesheet() { ?>
    <link rel="stylesheet" id="custom_wp_admin_css"  href="<?php echo get_bloginfo( 'stylesheet_directory' ) . '/style-login.css'; ?>" type="text/css" media="all" />
<?php }
add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );

Then create a file called style-login.css where you add the css for the login page elements. Place this file straight in the child theme directory.

 

You can read more about it here: http://codex.wordpress.org/Customizing_the_Login_Form. They even give you the various classes and IDs that you can style lower in the page.

Share this post


Link to post
Share on other sites

Posted · Report post

The CSS still isn't working. It must be something with the permalinks.

 

I understand hooks and filters, what I'm not clear on is how the Pagelines add body class filter is different from the WP standard one, and whether I need to also enter the bodyclass in the box in the admin panel and then register it in functions, do both, or neither.

Share this post


Link to post
Share on other sites

Posted · Report post

Thank you for your information Anthalis 

Share this post


Link to post
Share on other sites

Posted · Report post

pagelines_add_bodyclass is not a filter, it is a function. The function sets up the filter... its a shortcut basically. You use it like so:

 

pagelines_add_bodyclass( 'simon' );

 

That would add body class simon to your page.

 

You cannot simply do add_filter( 'body_class', 'simon' ); thats doing_it_wrong() If you took the time to read the docs for add_filter you would know that the second parameter has to be a function or callback. 

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Also enable WP_DEBUG in wp-config.php it will show the error PHP is getting. 

Share this post


Link to post
Share on other sites

Posted · Report post

Hi, just finally returning to this issue. I should have something to report tomorrow.

Share this post


Link to post
Share on other sites

Posted · Report post

OK, keep us posted.

Share this post


Link to post
Share on other sites

Posted · Report post

Anytime :)

Share this post


Link to post
Share on other sites