Customizing Content-Single.PHP Help Needed

Okay, so I’m putting some finishing touches on my content-single template and can’t seem to get it to behave properly.

I want the featured image to show at the top above the blog post on any regular post and for my custom post type Podcasts I want the podcast player to show in place of a featured image.

My code looks like this:

<article class="fl-post on-post" id="fl-post-<?php the_ID(); ?>" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
    <?php if(has_post_thumbnail() && !empty($show_thumbs)) : ?>

    <?php if($show_thumbs == 'above') : ?>
    <div class="fl-post-thumb">
        <?php the_post_thumbnail('large', array('itemprop' => 'image')); ?>
    </div>

    <?php else : ?>
    <div class="row">
        <div class="col-md-3 col-sm-3">
            <div class="fl-post-thumb">
                <?php the_post_thumbnail('thumbnail', array('itemprop' => 'image')); ?>
            </div>
        </div>
        <div class="col-md-9 col-sm-9">

            <?php endif; ?>

            <?php elseif (has_post_format( 'audio' ) || is_singular ('podcast')) : ?>
            <div class="audello-code">
                <?php the_field('audello_embed_code'); ?>
            </div>

            <?php endif; ?>

            <header class="fl-post-header">	... more stuff ... </article>

It’s working on my Single Podcast custom post type, which you can see here: http://www.theheroshow.com/podcast/episode001/

It’s not working on Single post, which you can see here:
http://www.theheroshow.com/challenged/paul-akers/

So something is wrong with my first if statement that’s making it not pull the featured image on single post display. Any help is appreciated.

Thanks!

Hey Richard,

Just letting you know that we are looking into this and will get back to you shortly.

Thanks!

KC

Hey Richard,

I would recommend creating another content file for your podcasts CPT. That way, you don’t have to use all those ifs which may be causing the issue?

So you can create a content-podcast.php file, copy the contents of the content-single.php file, and edit it accordingly to how you want to show the podcasts post. Then you can edit the content-single.php file as well to how you want standard single posts to show. Will that do?

Ben

Hey Ben,

Thanks. I’ve tried that. When I create a content-podcast.php file it doesn’t affect the podcast single display. I’m not sure if there is a setting somewhere or something… but doesn’t seem to matter what I name the file, where I put it, or anything. The only file I can get to adjust the content of the Podcast custom post type is that content-single.php file.

Any ideas?

Oh… and if I name it ‘single-podcast’ I can get it to affect the page… but all that shows up is the content of the post… the rest of the theme is missing.

Hey Richard,

Do you mind sharing temp admin access so we can check? I’ll just have you know though this is beyond our scope of support. I’d just like to check, and possibly refer this to the guys, just in case it’s something simple we just missed. :slight_smile:

Ben

Hey Richard,

Sorry, I think I figured out the issue. You’ll have to create a single-podcast.php file first. Then copy the files inside the single.php file, then change the part where it says <?php get_template_part(‘content’, ‘single’); ?> to <?php get_template_part(‘content’, ‘podcast’); ?>. Then just leave the content-podcast.php file like you want it. See if that works.

Edited steps.

Ben

Okay, sweet. That works beautifully for the single view of the podcast custom post type. Thanks for the help with that btw.

I have one more question on this… the archive view of the podcast custom post type.

If I understand… I’d follow the same steps.

Make archive-podcast.php file. Copy in the contents of index.php.

Make content-podcast_archive.php file (for the template part referenced in the archive-podcast.php file above). Copy in the contents of the content.php file. Adjust as necessary.

Change the

<?php while(have_posts()) : the_post(); ?>
					<?php get_template_part('content', get_post_format()); ?>
				<?php endwhile; ?>

In the archive-podcast.php file to:

<?php while(have_posts()) : the_post(); ?>
					<?php get_template_part('content', 'podcast_archive' get_post_format()); ?>
				<?php endwhile; ?>

Sound like that would work?

AHA! I would just like you to know Ben that the above totally worked.

had to put the appropriate comma in this line though:

<?php while(have_posts()) : the_post(); ?>
					<?php get_template_part('content', 'podcast_archive', get_post_format()); ?>
				<?php endwhile; ?>

That’s the fixed version for anyone who’s following and wants to be able to adjust templates for custom post types with Beaver Builder.

Also Ben… I know I’ve said it before, but… You’re a genius and I appreciate you helping me out over the holidays. Means a lot.

Ooh… Ben… One more quick question.

On line 5 of the content.php file (the one I have now customized and called content-podcast_archive.php and am using as the archive template part for my podcast custom post type)… there is this code:

$more_text = FLTheme::get_setting('fl-archive-readmore-text');

It’s referenced later on in the file on lines 48 & 51.

I’d like to customize the read more text just for the podcast post type.

Can I adjust that line 5 somehow to just put in the text I want to use?

I tried this (I know it shows my php newb-ness):
$more_text = My New Text For Button;

That totally did not work. Blew up the whole archive page. :stuck_out_tongue:

My other thought was to just create my own customizer panel…

tried adding this to my function.php file:

/* Content Panel */
FLCustomizer::add_panel('fl-content', array(
	'title'    => _x( 'CPT Content', 'Customizer panel title.', 'fl-automator' ),
	'sections' => array(
		
/* Podcast Archive Section */
		'fl-content-archives' => array(
			'title'   => _x( 'Podcast Archive Layout', 'Customizer section title.', 'fl-automator' ),
			'options' => array(

			/* Read More Text */
				'fl-podcast-archive-readmore-text' => array(
					'setting'   => array(
						'default'           => __('Read More', 'fl-automator'),
					),
					'control'   => array(
						'class' => 'WP_Customize_Control',
						'label' => __( '"Read More" Text', 'fl-automator' ),
						'type'  => 'text'
					)
				),
			)
		),
	)
));

That really didn’t work. Blew up the whole site. :slight_smile:

Hey Richard,

Could you try placing single quotes between the text like so…
$more_text = 'My New Text For Button';

Ben

Wow. That was easy. The single quotes totally work.

Btw - for those who are interested in actually adding their own customizer panels & controls for this instance. I got the code to work for that.

Still have no idea how to actually call the setting (meaning I don’t know what I’d write on line five to get the setting to pull into that template part).

But here’s the code for anyone who wants it:

/* Custom Post Type Panel */
function hero_bbct_customize_register( $wp_customize ) {
$wp_customize->add_panel( 'hero_cpt_content', array(
	    'title' => __( 'CPT Content', 'textdomain' ),
	) );

$wp_customize->add_section( 'hero_cpt_podcast_archives', array(
	    'title' => __( 'Podcast Archives', 'textdomain' ),
	    'panel' => 'hero_cpt_content',
	) );
$wp_customize->add_setting('hero_cpt_podcast_read_more', array(
						'default'  => __('Read Show Notes', 'fl-automator'),
					));

$wp_customize->add_control( 'hero_cpt_podcast_read_more', array(
						'class' => 'WP_Customize_Control',
						'section' => 'hero_cpt_podcast_archives',
						'label' => __( '"Read More" Text', 'fl-automator' ),
						'type'  => 'text'
					));			
}	

add_action( 'customize_register', 'hero_bbct_customize_register' );

Hey Richard,

Try checking the thread below and see if it helps. :slight_smile:
http://forum.wpbeaverbuilder.com/support/q/adding-a-second-line-tag-line-to-header/#post-21348

Ben