I'm using Fishpig's wordpress integration for magento.

I need to set even and odd class for posts in category list. Category page is written by post/list.phtml - code is below.

For basic magento catalog/category in my custom theme I use this script which works nicely.

<script type="text/javascript">decorateList('products-list','none-recursive'</script>

This is post/list.phtml and decorateList nor decorateGeneric functions don't work because in front end I get <li class="item">

<?php $posts = $this->getPosts() ?>
<?php if (count($posts) > 0): ?>
    <div class="post-list">
        <ul id="post-list">
            <?php foreach($posts as $post): ?>
                <li class="item<?php if ($post->isSticky()): ?> featured is-sticky<?php endif; ?> <?php echo $post->getPostFormat() ?>">
                    <?php echo $this->getPostRenderer($post)->toHtml() ?>
            <?php endforeach; ?>
        <script type="text/javascript">decorateList($('post-list'));</script>
        <script type="text/javascript">decorateGeneric($$('ul.post-list li.item'), ['odd','even','first','last'])</script>
        <?php echo $this->getPagerHtml() ?>
<?php endif; ?>

Does anyone know what could work for me?

Thank you in advance

  • Is the <script> tag first mentioned in your post accurate, as it's missing some characters that would cause it to error - if it is.
    – Navarr
    Oct 9, 2014 at 18:00
  • yes, it is. Everything is completely fine in source code.
    – sidlo
    Oct 9, 2014 at 19:49

1 Answer 1


I don't think your class selector is correct since you your element has an id and not a class name.

<div class="post-list">
    <ul id="post-list">

 decorateGeneric($$('ul.post-list li.item')

Try changing it to

<div class="post-list">
    <ul id="post-list" class="post-list" >

To add 'odd','even','first','last' to your LI tag

 decorateGeneric($$('ul.post-list li'), ['odd','even','first','last'])

To add 'odd','even','first','last' to your UL tag

 decorateGeneric($$('ul.post-list'), ['odd','even','first','last'])

Remove all your js except (then add them one by one to see what causing the conflict

<script type="text/javascript" src="/js/prototype/prototype.js"></script>
<script type="text/javascript" src="/js/lib/ccard.js"></script>
<script type="text/javascript" src="/js/prototype/validation.js"></script>
<script type="text/javascript" src="/js/scriptaculous/builder.js"></script>
<script type="text/javascript" src="/js/scriptaculous/effects.js"></script>
<script type="text/javascript" src="/js/scriptaculous/dragdrop.js"></script>
<script type="text/javascript" src="/js/scriptaculous/controls.js"></script>
<script type="text/javascript" src="/js/varien/js.js"></script>
<script type="text/javascript" src="/js/varien/form.js"></script>
<script type="text/javascript" src="/js/varien/menu.js"></script>
<script type="text/javascript" src="/js/mage/translate.js"></script>
<script type="text/javascript" src="/js/mage/cookies.js"></script>
  • Thank you for your concern but it did't help, do you have another idea, please?
    – sidlo
    Oct 9, 2014 at 19:48
  • Do you have any js error in your error console? Oct 9, 2014 at 19:50
  • Where do you want the odd/even on the li or ul tag. If on the li change it from $$('ul.post-list') to $$('ul.post-list li'). Then inspect element in chrome Oct 9, 2014 at 19:58
  • I have some errors in javascript. I'll try to fix them. I want to tag only li and that change didn't work either. But what's odd to me is that the same function decorateGeneric adds tag for product list (li) in catalog.
    – sidlo
    Oct 9, 2014 at 20:21
  • Did you include /js/varien/js.js in your page header? Oct 9, 2014 at 20:31

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.