WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How can I add a formatted post title to this? (4 posts)

  1. rwilki
    Member
    Posted 1 year ago #

    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

  2. Jonathan Lake
    Member
    Posted 1 year ago #

    <h2><?php the_title(); ?></h2>

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

  3. rwilki
    Member
    Posted 1 year ago #

    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;
    ?>
  4. rwilki
    Member
    Posted 1 year ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic