• It works when setting the colors for each category. To get the colors, you could use the following code:

    $colors = get_option('colored-categories');
    if ($colors !== false)
    	$color = $colors[$category_id];
Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m sorry if this is a stupid question, but what exactly do you mean? Where in the code should that go, and then what do I use to call the colors?

    For example, I’m currently mucking about with the following snippet for the background colors of my posts:

    .entry-content {
    	background-color: yellow;
    }

    Is there something I can call instead of “yellow” (or a hex code or whatever else)? I’m using Jetpack to add CSS to my theme so I don’t mess anything up too badly, so I’m not even sure if it’s managing to add your bit of code to the right stylesheet.

    Thanks!

    Thread Starter lessan

    (@lessan)

    So by saying the plugin ‘works’, I meant that you can set the color for each category (from the admin panel where you add/edit categories), but that’s about it. There is no mechanism for being able to use those colors on your site.

    The three lines of code I pasted above are PHP code that you put somewhere in your theme. You’ll need to edit the theme and paste them where you need them. Then you can use the contents of the $color variable somewhere in the HTML to do the styling. The colors are custom for each category and are not available in your CSS file, so you would use inline CSS on the tag you wish to style.

    For example, if you are showing the category title at the top of each blog post, just under the post title, you may have the following code somewhere in your theme’s index.php:

    <h2><?php echo single_term_title(); ?></h2>

    You could use this plugin to have the category title be displayed in a custom color, like this:

    <?php
    $category_id = get_query_var('cat');
    $colors = get_option('colored-categories');
    if ($colors !== false)
      $color = $colors[$category_id];
    ?>
    
    <h2 style="color:<?php echo $color; ?>">
      <?php echo single_term_title(); ?>
    </h2>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Works, but needs docs’ is closed to new replies.