• Hi,

    Sorry if this questions has been asked before, but I haven’t found an answer.

    Let me explain my issue. I’m trying to add a ‘Last modified’ above my posts. For this I use the Last Modified Timestamp plugin. I have added the correct php code to ‘single/content.php’ which I duplicated in my child theme, the php code is inserted before the_content().
    The ‘Last Modified’ time stamp is showing, so far so good. The problem is that I’m also using ‘Super Socializer’ plugin and I would like to have the ‘Last modified’ timestamp show below the sharing icons.

    To achieve this I think that instead of modifiying the single/content.php I need to make my own post template.

    So I copied page.php to my childtheme and added the timestamp php code, however the template is not showing when I’m creating a post?

    So my questions are these:

    1. What’s the right method to add custom text for each post before the post title, but after social sharing buttons?
    2. If my method is correct, how do I enable the template I’ve created?

    Thanks in advance for looking into this,

    Kind regards,

    Jonas

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author oceanwp

    (@oceanwp)

    Hello, to do something like this, you need to edit the layout.php file in the single folder, not the page.php.
    You need to remove the foreach, your file will look like this:

    <article id="post-<?php the_ID(); ?>">
    
    	<?php
    	// Get posts format
    	$format = get_post_format();
    	$format = $format ? $format : 'thumbnail';
    			
    	// Featured image
    	get_template_part( 'partials/single/media/blog-single', $format );
    
    	// Title
    	get_template_part( 'partials/single/header' );
    
    	// Meta
    	get_template_part( 'partials/single/meta' );
    
    	// Content
    	get_template_part( 'partials/single/content' );
    
    	// Tags
    	get_template_part( 'partials/single/tags' );
    
    	}
    
    	// Social Share
    	if ( OCEAN_EXTRA_ACTIVE ) {
    
    		do_action( 'ocean_social_share' );
    
    	}
    
    	// Next/Prev
    	get_template_part( 'partials/single/next-prev' );
    
    	// Author Box
    	get_template_part( 'partials/single/author-bio' );
    
    	// Related Posts
    	get_template_part( 'partials/single/related-posts' );
    
    	// Comments
    	comments_template(); ?>
    
    </article>
    Thread Starter jonas541

    (@jonas541)

    Thanks for your fast reply. I’ve did it. Two questions.

    1. The template is not showing under ‘Post Attributes’ Template
    2. I’m also getting this error:
    Parse error: syntax error, unexpected ‘<‘, expecting end of file in /home/gojonas5/public_html/wp-content/themes/oceanwp-child/partials/single/layout.php on line 30

    3. Where do I have to add this: <span>Last updated: </span><?php the_last_modified_timestamp(‘custom’, array(‘format’ => ‘%date%’)); ?>

    so it displays before the text of my article, but after my SuperSocializer buttons?

    Thanks for your help,

    Jonas

    • This reply was modified 8 years, 8 months ago by jonas541.
    Theme Author oceanwp

    (@oceanwp)

    I don’t know where is your SuperSocializer buttons, but if you want to add it before the post content add it before:

    get_template_part( 'partials/single/content' );
    Thread Starter jonas541

    (@jonas541)

    I managed to do that initially however the problem is that it first shows the timestamp, then the socializer buttons then the content. Where I want it to be first socializer buttons, then timestamp, then the content.

    Theme Author oceanwp

    (@oceanwp)

    Is it possible to display the socializer buttons via shortcodes? If yes, you just need to add the shortcode before timestamp.

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

The topic ‘Custom Post Template’ is closed to new replies.