WordPress.org

Ready to get started?Download WordPress

Forums

how to add category title into a post (2 posts)

  1. shortbus1662
    Member
    Posted 6 years ago #

    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.

  2. bekabug
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic