WordPress.org

Ready to get started?Download WordPress

Forums

comment_form for different templates (3 posts)

  1. hittheroadjack
    Member
    Posted 1 year ago #

    I am struggling now for a while with this:
    For different categories on my blog, I use different styling and try to implement also different styling for the comments.
    Unfortunately, comment_form() is using a 'hard wired' CSS id="respond".My theme has a style.css and #respond is defined. But how to achieve the second, different styling (background, font, border) for within the comment form. Can I override the respond-ID temporarily (i.e. for a certain category) with a #respond2 somewhere ? Whatever I do in my comments.php only wraps around the comment_form but does not replace it.
    I must confess, CSS is not one of my favorite - may be, there is a very simple way to do it?

  2. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    First, ensure that your Theme properly incorporates body_class():

    <body <?php body_class(); ?>

    Then, if you can specify the contexts for which you want to override the #respond CSS, I can help point you in the right direction.

  3. hittheroadjack
    Member
    Posted 1 year ago #

    Yes, the theme incorporates the body_class in header.php like so

    </head>
    <body <?php body_class(); ?>>
    <?php $theme->hook('html_before'); ?>
    <div id="wrapper">
    <div id="container">

    What I am trying to do is the following in my comments.php :

    <?php if ( have_comments() ) {
    		$cat = get_the_category();
    		if($cat[0]->cat_name == 'DEdK2'){
    			?><div id="commentsDEdK"><?php
    		}
    		else{
    			?><div id="comments"><?php
    			}
    	?>

    This works for the comments because it is an id outside of comment_form(). When I try to do the same with #respond and #respondDEdK it won't work because #respond is placed inside comment_form(). Thus, my comments have the right styling but not my comment form! It always shows what my style.css is defining for #respond. No way to switch over for just this one category.

Topic Closed

This topic has been closed to new replies.

About this Topic