WordPress.org

Support

Support » How-To and Troubleshooting » how to add category title into a post

how to add category title into a post

  • shortbus1662
    Member

    @shortbus1662

    I want to make a post but dynamically insert the category title of the page the post falls under into the body of the post.

    Is there a way to insert the category title, post title, category slug, etc., into the post?

    I’d really appreciate any information that anyone can provide.

Viewing 1 replies (of 1 total)
  • bekabug
    Participant

    @bekabug

    Forgive me, but I don’t see how this could be useful. You can much more easily add this information into a post meta area.

    That said…

    I have used the runPHP plugin (2.3.3 as of right now) to execute PHP in posts. You could, in theory (i haven’t tested this) run something like:

    <?php
    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' ';
    }
    ?>

    …in a post. If you didn’t want to have to remember the code all the time you could modify your quicktags and make a new button for it.

Viewing 1 replies (of 1 total)
  • The topic ‘how to add category title into a post’ is closed to new replies.