ThemeShaper Forums » Thematic

Using functions rather than templates

(6 posts)
  • Started 2 years ago by cregy
  • Latest reply from Chris
  • This topic is not resolved
  1. Hi

    I know when I code a standard wp theme if I want to change the way something looks for a category I can use a template. However, with thematic I am wondering if functions is a better route. If you take a look at this site:
    http://lostwithiel.org.uk/
    I have a rotating gallery in the header. I only want this to appear in the home page so I am wondering if there is some code I can put in the function.php that says only show this on the home page.

    However, if possible when they start looking at other pages instead of the rotating gallery I would like several static images that only change when you visit another page.

    Is this possible with a function script please? If so is there anyone out there that will help write it for me please?

    Thanks

    Rich

    Posted 2 years ago #
  2. Hey Rich,

    try to encapsulate your function call for the rotating gallery into:

    if (is_home() || is_front_page()) {
        <-- your function call -->
    }

    This will take care that the rotating gallery will only show up on your home page.

    Btw.: Only take the function call .. we need the DIV for the pictures.

    The rest could be done using CSS:

    body.slug-accommodation #headerslide {
        background: url(images/accomodation.jpg) no-repeat;
    }
    body.slug-food-and-drink #headerslide {
        background: url(images/food-and-drink.jpg) no-repeat;
    }
    .. and so on

    You might need to add some more settings like width and height.

    Let me know if this works or if you need more help.

    Cheers,

    Chris

    Posted 2 years ago #
  3. Hi Chris

    Thanks for the reply. I tried pasting the code into the functions.php and came up with an error. So then tried it into the header.php and got an error! So obviously I'm doing something wrong.

    if (is_home() || is_front_page()) {
        <?php echo nggShowSlideshow(gallery2,660,200) ?>
    }

    Where should I place the above please and should I wrap it with php tags?

    I left the div in place in the header. I put a &nbsp; in the div to ensure the div had something in it.

    I presume with the second part does wp recognise the word slug please?

    Thanks

    Rich

    Posted 2 years ago #
  4. Hey Rich,

    could you please post the original code you used to implement the slideshow? Need it to build the rest around it.

    slug-xxxxx is a class built by Thematic. Look into the source code of a page or single post within FireFox or IE and search for '<body class='.

    Posted 2 years ago #
  5. Hi Chris

    Thanks for the help.

    `<div id="header">

    <?php thematic_header() ?>

    <div id="headerslide">
    <?php echo nggShowSlideshow(gallery2,660,200) ?>
    </div>

    </div><!-- #header-->'

    Rich

    Posted 2 years ago #
  6. Hey Rich,

    try this one:

    <div id="header">
    
    <?php thematic_header() ?>
    
    <div id="headerslide">
    <?php
    if (is_home() || is_front_page()) {
         echo nggShowSlideshow(gallery2,660,200);
    } ?>
    </div>
    
    </div><!-- #header-->

    Haven't tested it, but it should work.

    Cheers,

    Chris

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.