- This topic has 2 replies, 2 voices, and was last updated 8 years, 12 months ago by Puro Support.
Tagged: Child Theme entry meta ultra
- AuthorPosts
- December 29, 2015 at 12:04 am #2875
jfisherfbmParticipantHello,
I am trying to figure out how to make a custom single.php file for a specific category.
Typically, I create the file single-default.php, which is derived from the original single.php file. Then replace the code in single.php with the following:
<?php
if (in_category(‘category-name’)) {include (TEMPLATEPATH . ‘/single-category-name.php’);
}
elseif (in_category(‘another-category’)) {include (TEMPLATEPATH . ‘/single-another-category.php’);
}
else { include (TEMPLATEPATH . ‘/single-default.php’);
}
?>This will give me the ability to have a custom template for the single blog posts, but this method doesn’t work with the Ultra theme for some reason.
I get a white page when trying to view a single blog post from a category listing.
Is there another way to have a custom template for the single blog posts within a specific category.
Basically I just want to remove the entry-meta from one category, but leave it on for the other categories.
P.S. I really like this theme, and I am interested in purchasing the pro version; however, I need this to work before I can purchase the theme.
Thanks in advance!
December 29, 2015 at 2:31 am #2877
Puro SupportKeymasterHi jfisherfbm
It’s great to hear from you. We can probably just do this from a child theme functions.php file. What is the ID of the category you don’t want entry meta to appear on?
December 29, 2015 at 3:01 am #2878
Puro SupportKeymasterThere are many ways this can be done. Here is a quick one. Copy single.php to your child theme. Change the .entry-header div as follows:
<header class="entry-header <?php if ( in_category( '7' ) ) { echo "custom-cat"; } ?>"> <div class="container"> <h1 class="entry-title"><?php echo get_the_title(); ?></h1><?php ultra_breadcrumb(); ?> </div><!-- .container --> </header><!-- .entry-header -->
We’ve added:
<?php if ( in_category( '7' ) ) { echo "custom-cat"; } ?>
Next, wrap the entry-meta div in a conditional:
<?php if ( ! in_category( '7' ) ) : ?> <div class="entry-meta"> <div class="container"> <div> <?php ultra_posted_on(); ?> </div> </div><!-- .container --> </div><!-- .entry-meta --> <?php endif; ?>
In both cases, replace the category ID 7 with yours.
Finally, in the style.css file of your child theme or in a Custom CSS plugin, insert:
.single .entry-header.custom-cat { margin-bottom: 2.67857em; }
- AuthorPosts
You must be logged in to reply to this topic.