Support » Fixing WordPress » Including different fixed blocks withs cats.

  • I am new to WordPress, so apologises if this is has been dealt with before: I have searched around for a couple of hours and have not yet found an answer.
    I want to include a different block of text (it will be introductory text) on each category page. Each block of text is associated with one category only.
    I think this is probably best achieved by adding some code to the index.php file, just after the line
    <div id=”content”>
    To include the text I will use the php include function (I have actually got this working as:
    <?php include(‘my_block_of_text.php’); ?>
    This is the result:
    What I can not work out is how to include a different block of text for each category. My thinking is that an ‘if’ or ‘switch’ statement might do the trick, but I am not sure what I will be testing for i.e. $cat=”1″ or something else
    Any suggestions, links to others work, would be gratefully appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Currently doing that as a plugin, if you can wait a bit….

    Thanks for your response. I am happy to wait a while (i guess you are thinking of a few weeks?). Is there anything I can do to help you – not that I can write PHP, but there might be something 🙂

    Yes, one. I tweaked so much my index that I can not get straight between which tag the text is supposed to show up 😛 So if you can telle me that you want it basically in, for example, <div class=”storycontent”> and </div> or so, that could help. And .. no, should be ready in a few days ^^;

    There we are 🙂
    Hope it corresponds to what you wanted, if not, ask away 🙂
    English discussion of the plugin, please post on this thread. French, go on my blog 😉

    I have had a quick ‘play’ with your code and it seems to do exactly what I want. Thank you for your help. If I have any more (of your) smart ideas I will post again 🙂

    I have tested the code some more and have found a problem. I am not using the standard wordpress template, but I slightly modified version of a three colum design (possibly from digeratipeninsula).
    When I follow your instructions and add the ‘showintro’ snippet of code to index.php, it works, but also moves the items from the right hand column (categories) and left and column (search) neatly underneath the bottom of my central column that contains the comments.
    I am guessing that there is an issue with the stylesheet somewhere, but I can not understand how adding the function will cause this problem. Any thoughts?

    Well, appart from the typo that was corrected, I suppose you do not use exactly the same things (div, p, …) after and before that I do, and that the plugin gives as *default*.
    Just try to modify that in the plugin (or use the advanced function) to have the blog display the same that you use for other posts…
    Change :
    $showbefore = '<h3 class="storytitle">', $showmiddle = '</h3><div class="storycontent">', $showafter = '</div>' by what you want used… I do not know what you use…

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Including different fixed blocks withs cats.’ is closed to new replies.