• Resolved sms-web

    (@sms-web)


    Hello-

    I’m using a theme (WPESP) that is primarily a portfolio theme. It didn’t come with traditional blogging capabilities. The portfolio is made up of a series of posts. Each of those posts handles each individual piece of work. Each post has a series of custom fields that handle descriptions and images. From the main portfolio page, you can click on any individual piece of work and go to the “case study” page. Here’s a sample screenshot of how it’s supposed to look:

    http://smswebdevelopment.com/wordpress/wp-content/themes/wpesp-portfolio/style/images/caseStudy.jpg

    I decided to do a workaround to incorporate a blog into this site. I’m using a plug-in called “bloginblog” to link in posts from the category “blog” into a static page caled “blog”. All worked great at this point – no conflicts with the plug-in. To handle commenting, I had to add in comments.php and single.php, which did not come with the theme. At any rate, I massaged these file to handle commenting for “blog” and all works great.

    Here’s where my issue started: When I go to the “case study” page from the portfolio, single.php has replaced all of the custom fields and sidebar.

    I tried using a conditional statement in single.php:
    <?php if( in_category('blog') ): ?><?php comments_template(); ?><?php endif; ?>

    All this did was remove the comments template. There is still something within single.php that is taking precedence over the case study page. See here:

    http://smswebdevelopment.com/wordpress/?p=17

    How can I get single.php to only work with the “blog” category and not override the “case study” page? Any help is greatly appreciated!

    Thanks!
    Steven

Viewing 5 replies - 1 through 5 (of 5 total)
  • Find the original file that was used to show the case study page. For example, suppose it is case-study.php. Rename your single.php as single-blog.php. Create a new single.php with this code in it:

    if ( in_category(14)) {  // Replace 14 with your Blog category ID
      include(TEMPLATEPATH . '/single-blog.php'); }
    else {
      include(TEMPLATEPATH . '/case-study.php');
    }
    Thread Starter sms-web

    (@sms-web)

    Hello vtxyzzy,

    Thanks so much for your response! You’ll have to excuse my lack of php skils. I’m relatively new at it. Anyway, I think I’m getting closer, but still it’s not quite there and it may be my (mis)placement of the code you supplied.

    Should the new single.php contain only the code you supplied? If not, where within the existing code should it be placed? And finally, does it need an “endif” statement?

    Thanks again!

    The new single.php should contain only the code below, no ‘endif’ needed since braces are used. Be sure to replace the ’14’ with your Blog category id, and ‘case-study.php’ with the name of the file that used to show your case studies.

    <?php
    if ( in_category(14)) {  // Replace 14 with your Blog category ID
      include(TEMPLATEPATH . '/single-blog.php'); }
    else {
      include(TEMPLATEPATH . '/case-study.php');
    }
    ?>

    If this solves your problem, please be sure to use the dropdown at top right to mark this topic ‘Resolved’.

    Thread Starter sms-web

    (@sms-web)

    Thanks so much! With the addition of the header and footer call, that’s it! Works great!

    Thanks again!

    You are welcome!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Single.php Overriding Custom Fields in Other Pages’ is closed to new replies.