WordPress.org

Forums

Custom Category Templates
[resolved] body_class() Bugfix (6 posts)

  1. Duncan
    Member
    Posted 2 years ago #

    There is a small bug in the script while generating the body_class() based on the file-name:

    A generated class i.e.: "category-template-category-tpl-xyz.php" will not work when referred to the class by CSS.

    Find details and solution here: Bugfix for WordPress Plugin “Custom Category Templates”

    Hope that helps.

    Frank

    http://wordpress.org/extend/plugins/custom-category-templates/

  2. Duncan
    Member
    Posted 2 years ago #

    There's a direct download link to the revised file as well.

    Regards,
    Frank

  3. Sith Lord Goz
    Member
    Posted 2 years ago #

    I also see that this plugin doesn't add CSS classes to the body tag - your download link seems to be broken. Could you please clarify the bug fix?

    Thanks!

  4. Sith Lord Goz
    Member
    Posted 2 years ago #

    Nevermind - I discovered my parent theme was overriding the body_class hook.

  5. Sith Lord Goz
    Member
    Posted 2 years ago #

    Here's the issue and the bugfix for @shazdeh :

    Issue:
    ------
    $this->template is not HTML-class-safe (it contains a period because it is pulling the PHP file name

    Fix:
    ----
    Replace body_class() fn on line #56 of init.php with:

    function body_class( $classes ) {
    	$template = sanitize_html_class( str_replace( '.', '-', $this->template ) );
    	$classes[] = 'category-template-' . $template;
    	return $classes;
    }
  6. shazdeh
    Member
    Plugin Author

    Posted 2 years ago #

    Thank you both for the fixes. I'll add it to the next version.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Category Templates
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic