WordPress.org

Ready to get started?Download WordPress

Forums

How to get categories and tags? (2 posts)

  1. Daniel Fru?y?ski (sirzooro)
    Member
    Posted 5 years ago #

    I am writing handler for save_post action, and I need to get list of categories and tags of saved post. Unfortunately this code doesn't work for me:

    function save_post($post_ID)
    {
    	echo "<pre>\n";
    	$cats = wp_get_post_categories($post_ID);
    	print_r($cats);
    	$tags = wp_get_post_tags($post_ID);
    	print_r($tags);
    	die("");
    }

    Both wp_get_post_categories() and wp_get_post_tags() returns empty arrays. Why this code doesn't work? Is any other way to get categories and tags in save_post handler (or at least count of them)?

  2. MichaelH
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic