• Resolved Twist360

    (@twist360)


    Hi Everyone,

    I was hoping somebody could help me. I think your plugin is fantastic, we have deployed on our new site however we use <body> classes to switch the background colour depending on which section you are in.

    We are looking to add a body class to the job listing page. I have created a single-job_listing.php in my theme folder but I cannot add the body class there.

    Does anybody know how I can add this code:

    <?php add_filter('body_class','job_listing');?>

    To either the single-job_listing,php or more likely the functions.php file of my theme but ONLY for the job listings?

    I have tried to add the following to my functions.php file but it did not work:

    add_filter( 'body_class', 'sp_body_class' );
    
    function sp_body_class( $classes ) {
    	if ( is_page( 'single-job_listing' ) )
    		$classes[] = 'job_listing';
    		return $classes;
    }

    Any help would be appreciated.

    https://wordpress.org/plugins/wp-job-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    A single job listing already by default appends body classes.

    https://dl.dropboxusercontent.com/s/ex0jmbg39ykf9pl/2014-09-19%20at%2019.21.png?dl=0

    single-job_listing

    Thread Starter Twist360

    (@twist360)

    Thanks Mike, Maybe we are stripping it somewhere Do you know if VC does this as my page shows:

    <body class=" wpb-js-composer js-comp-ver-4.3.3 vc_responsive">

    Appreciate this is our application issue and not the plugin in that case.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    WordPress adds more than that – maybe your header.php is missing body_class()?

    Thread Starter Twist360

    (@twist360)

    Hi Mike,

    Thanks for your help, the body tag was being included in the header.php but after some googling, the following code fixed the problem

    if( ! is_page_template('single-job_listing.php') )
    {
    	add_filter( 'body_class', 'job_body_class' );
    }
    
    function job_body_class( $classes ) {
    
         if( ! is_page_template() )
              $classes[] = 'job_listing';
    
        return $classes;
    }

    EDIT: Actually this just added About to all pages… still googling 🙂

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    If you want to do it manually, try is_singular( ‘job_listing’ )

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add Slug’ is closed to new replies.