Support » Developing with WordPress » modified date of category list

  • Willem 2

    (@willem-2)


    I want to display the date that something in the category list has changed. The following code shows the date when something has changed in the text of the page. (I use a plugin to make this code a shortcode.)

    <? php the_modified_date ("j F Y H: i"); ?>

    The list of categories that you see on my blog is generated with the following code in functions.php.

    function show_categories_fn () {
    return wp_list_categories (“echo = 0 & title_li”);
    }
    add_shortcode ("show_categories", "show_categories_fn");

    Can someone help me with the full php code so that the date will only change when something in the category list has changed?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Category terms do not maintain modification dates like pages and posts do. You’d need to keep track of the date yourself, perhaps as an option value. Hook into one of the term update hooks and update the option value anytime the hook fires.

    Thus you would add this date data to the shortcode output string showing when any term was last updated.

    Willem 2

    (@willem-2)

    I’m sorry, I’m not a programmer. I Understand the beginning of what you said. But I don’t understand it from where you say: ‘You’d need to keep track ….’ (Maybe it’s because I don’t understand the meaning of ‘hook’.)

    I still hope you or sombody else can help me with some code.

    Willem

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘modified date of category list’ is closed to new replies.