ThemeShaper Forums » Thematic

[closed]

Modifying the single post content

(4 posts)
  • Started 10 years ago by travismallen
  • Latest reply from Chris
  • This topic is resolved
  1. Hi all,

    I thought I was on the right track with this but it does not change anything. I'm trying to replace the content.

    function my_singlepost() {
    	if (is_single() && post_is_in_descendant_category(get_term_by( 'name', 'gallery' ))):?>
    		<div class="single-gallery-post">
    			<div class="single-gallery-image">
    			Image holder...
    			</div>
    			<div class="single-gallery-cap">
    			Caption holder...
    			</div>
    		</div>
    	<?php endif;?>
    <?php }
    add_action('thematic_content','my_singlepost');

    Do I need to have a function to remove something first, or am I way off on this one?

    Thanks, Travis

    Posted 10 years ago #
  2. Hi Travis,

    *sigh* .. I think I'm going to rename this function.

    As far as I got your code you are trying to exchange the loop for a single post?

    Chris

    Posted 10 years ago #
  3. Hey Chris,

    No, on single.php I want to change the content. You have plenty of great examples of how to change a loop :)

    In short, I have an image attached and I want to use the post text as caption text next to the image. There's some javascript (shadowbox) I want to use with it as well so I'm trying to replace it.

    Thanks, Travis

    Posted 10 years ago #
  4. Then you need to filter the_content:

    function my_singlepost($post) {
    	if (is_single()&& post_is_in_descendant_category(get_term_by( 'name', 'gallery' ))) {
    		$mypost = '<div class="single-gallery-post">' . "\n";
    		$mypost .= '<div class="single-gallery-image">' . "\n";
    		$mypost .= '	Image holder...' . "\n";
    		$mypost .= '</div>' . "\n";
    		$mypost .= '<div class="single-gallery-cap">' . "\n";
    		$mypost .= $post;
    		$mypost .= '</div>' . "\n";
    		$mypost .= '</div>' . "\n";
    		$post = $mypost;
    	}
        return $post;
    }
    add_filter('the_content', 'my_singlepost');

    Did a short test without that post_is_in_descendant_category thing to see that the basics are working :)

    Chris

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.