Support » Fixing WordPress » How can I add a formatted post title to this?

  • Resolved rwilki

    (@rwilki)


    This works exactly like I need, with the exception of a post title. I need it formatted with <h2> tags.

    <?php
    $post_id = 26;
    $queried_post = get_post($post_id);
    $content = $queried_post->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    ?>

    Thanks,
    Bob

Viewing 3 replies - 1 through 3 (of 3 total)
  • <h2><?php the_title(); ?></h2>

    Don’t forget to remove the PHP tags if you already have them.

    Thanks Jonathan. Already have the tags.

    So something like:

    <?php
    $post_id = 26;
    $queried_post = get_post($post_id);
    $content = $queried_post->post_content;
    <h2>the_title();</h2>
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    ?>

    I got it. Here’s the code if anyone would like it…

    <?php
    $post_id = 26;
    $queried_post = get_post($post_id);
    ?>
    <h2><?php echo $queried_post->post_title; ?></h2>
    <?php $queried_post->post_content;
    $content = $queried_post->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content; ?>

    Thanks for your help Jonathan…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I add a formatted post title to this?’ is closed to new replies.