ThemeShaper Forums » Thematic

Dynamic Classes - Include Slug

(4 posts)
  • Started 9 years ago by patdryburgh
  • Latest reply from logicoder
  • This topic is resolved
  1. Hey Ian,

    Been a while since I've had time to toy around with Thematic. I'm back at it right now and have a question about dynamic classes. I am trying to add a dynamic class to the body class that gives me the page or post's slug. So, if the title of the page is "Advancement Centre," the dynamic class would add "advancement-centre" to my body class. Any ideas?

    Thanks bud! Hope you had a great Christmas.

    Posted 9 years ago #
  2. Hi,

    just add this line to the thematic_post_class function in dynamic-classes.php before line 175:

    $c[] = 'slug-' . $post->post_name;

    Et voilĂ , you will have a class named slug-something (e.g. slug-home, slug-about).

    Hope it helps,
    Marco Del Tongo

    Posted 9 years ago #
  3. Here's the diff:

    Index: dynamic-classes.php
    ===================================================================
    --- dynamic-classes.php (revisione 259)
    +++ dynamic-classes.php (copia locale)
    @@ -25,6 +25,9 @@
    $postID = $wp_query->post->ID;
    the_post();

    + // Adds post slug class, prefixed by 'slug-'
    + $c[] = 'slug-' . $wp_query->post->post_name;
    +
    // Adds 'single' class and class with the post ID
    $c[] = 'single postid-' . $postID;

    @@ -80,6 +83,10 @@
    $pageID = $wp_query->post->ID;
    $page_children = wp_list_pages("child_of=$pageID&echo=0");
    the_post();
    +
    + // Adds post slug class, prefixed by 'slug-'
    + $c[] = 'slug-' . $wp_query->post->post_name;
    +
    $c[] = 'page pageid-' . $pageID;
    $c[] = 'page-author-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));
    // Checks to see if the page has children and/or is a child page; props to Adam
    @@ -171,6 +178,9 @@
    if ( ++$thematic_post_alt % 2 )
    $c[] = 'alt';

    + // Adds post slug class, prefixed by 'slug-'
    + $c[] = 'slug-' . $post->post_name;
    +
    // Separates classes with a single space, collates classes for post DIV
    $c = join( ' ', apply_filters( 'post_class', $c ) ); // Available filter: post_class

    Posted 9 years ago #
  4. In SVN.

    Posted 9 years ago #

RSS feed for this topic

Reply

You must log in to post.