Jump to content


Photo
* * * * * 1 votes

Help on adding new body classes


  • Please log in to reply
23 replies to this topic

#1 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 10:21 AM

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?

 

 



#2 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 25 January 2013 - 11:00 AM

HI,

 

The Body class is working for me

 

Please Login or Register to see this Hidden Content

Please Login or Register to see this Hidden Content

 

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

 

Please Login or Register to see this Hidden Content

Replace uncategorized and abc with your category names.



#3 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 11:41 AM

Unfortunately this does not work at all.



#4 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 25 January 2013 - 11:52 AM

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

 

As I have both working on my test site



#5 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 11:58 AM

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".



#6 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 25 January 2013 - 12:09 PM

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



#7 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 12:13 PM

It's still on a local installation.



#8 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 25 January 2013 - 12:17 PM

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.

Please Login or Register to see this Hidden Content



#9 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 12:27 PM

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?



#10 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 25 January 2013 - 12:36 PM

Try this instead:

 

Please Login or Register to see this Hidden Content

 

To add a background image, use the following:

 

Please Login or Register to see this Hidden Content

For information on filters, I recommend reading the Wordpress article - 

Please Login or Register to see this Hidden Content

 

You can find a list of actions/filters here - 

Please Login or Register to see this Hidden Content

 

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

 

An example of a filter can been seen here - 

Please Login or Register to see this Hidden Content



#11 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 25 January 2013 - 01:53 PM

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.



#12 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 25 January 2013 - 02:01 PM

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. 


  • massmosaic likes this

#13 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 28 January 2013 - 09:38 AM

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:

 

Attached Files



#14 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 28 January 2013 - 10:40 AM

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.



#15 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 05 February 2013 - 10:55 AM

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.



#16 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 05 February 2013 - 11:08 AM

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.

 

Please Login or Register to see this Hidden Content

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?



#17 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 05 February 2013 - 02:31 PM

!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?



#18 Danny

Danny

    Is Awesome!

  • Moderators
  • 17919 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 06 February 2013 - 01:38 PM

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 - 

    Please Login or Register to see this Hidden Content

  • Add the custom CSS you're using to our pastie service -

    Please Login or Register to see this Hidden Content

  • 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 > 


#19 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 06 February 2013 - 03:40 PM

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



#20 idea15

idea15

    Advanced Member

  • Members
  • 58 posts
  • Country: Country Flag

Posted 27 February 2013 - 11:47 AM

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