• Hi,

    When creating a new post and assigning it to a specific category (say, video) i would like the post to be displayed using a specific (video)single.php template.

    Does anyone know the code to make this work?

    i have 4 categories i would like to do this with.

    When selected:

    cat1 or cat 2 = newssingle.php
    cat3 or cat 4 = videosingle.php

    Any help would be fantastic!

    Thankyou.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    if (in_category(1) || in_category(2)) include 'newsingle.php';
    else if (in_category(3) || in_category(4)) include 'videosingle.php';
    Thread Starter chris2006

    (@chris2006)

    Thats great thanks!

    Do i add this to the index.php template in the loop?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    You’d probably want to put that in the single.php file.

    did this work for you? i’m having the same problem, but so far i haven’t put that code in a place that doesn’t make my page go wacky.
    where in the single.php file did you put it?

    I would like to link to a different single.php from my archive page.

    Let’s say home.php links to single.php
    and archive.php links to single_x.php

    Any ideas?

    Felix

    //—> I just opened a new question for this!

    https://www.ads-software.com/support/topic/24125

    ok i used this but it looks like its putting one template on top of the other. single_x displays properly but i want it to display INSTEAD of single.php not alongside it. should i use another word besides ‘include’?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use a specific single.php template for specific categories’ is closed to new replies.