0

So, I get how to easily create separate blog "feeds" in a single blog by using categories. While I can style the category feed pages differently, unfortunately they both just provide links to the same style/theming of individual posts. I'm curious if there is any way for me to style the individual posts differently based on what feed category they were viewed from?

Essentially, I want to have a feed for events and a feed for images, where the feed for image posts links to more gallery styled pages and the feed for events links to a more traditional blog post styled page. Blog posts could (and likely would) be categorized as both types, so how the post is displayed would be entirely dependent on how the user got to it.

Anything like this possible?

2 Answers 2

0

I suspect I do not entirely follow your meaning when you say 'feeds'.

However, you say that you want a

way for me to style the individual posts differently based on what feed category they were viewed from?

I may be off base, but if you really mean to say that you want to style a post differently based on the category that it is categorized within, then the in_category template tag may help.

It will not alter the display based on the link that someone clicks just before they arrive the post in question, but instead will alter the display based on your rules set with that conditional tag based on how you categorized the post in the first place.

ex. if you have a post My Red Post categorized with the Category of Red

You could set a rule that styles the background color of the post (or any other formatting ) to display red when the condition is met

if ( in_category( 'red' )) {
// the instructions given after this point could direct the changing of the background to red...
} elseif ( in_category( 'green' )) {
    // instructions given after this point could change background to green...
} else {
    // no change from the standard template...
}

Not sure if that answers what you are looking for??? :)

WordPress codex on in_category template tag

1
  • No, that wouldn't work because some posts could have both categories. I dug a bit deeper tonight and it looks like what i want just isn't possible. Basically I want two separate blogs split out by category, where some posts could fall under both. Depending on which category you try to view the individual post from would define the styling. I was trying to do it this way to avoid making a custom templated page and having to roll my own pagination but it looks like I'll have to go that route after all. Thanks for taking a stab anyways!
    – James
    Commented Oct 26, 2012 at 1:51
-1

You could write different css-code for each and place all of these in your style.css. Make each separate style depend on a wrapper. Like this:

.styleA a {
      //style of links on page with styleA
}

.styleB a {
      //style of links on page with styleB
}

Then you wrap all page in an element with the style you want:

<div class="styleA">
     ....
     <a href="...">This link will have the style A</a>
     ....
</div>
2
  • I'm not trying to style the individual links, I'm trying to style the post page that the links GO TO differently based on what feed the user came from. This isn't a CSS issue, but a wordpress one.
    – James
    Commented Oct 24, 2012 at 13:47
  • You must be able to change the link, like you pass the styling as a parameter. Then apply that parameter as wrapping described in my answer.
    – Gunslinger
    Commented Oct 27, 2012 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.