0

I want to write a function which has to retrieve meta data of a post (LearnDash quiz) at the moment when it's published.

function add_quiz_shortcode($new_status, $old_status, $post) {
  if ($post->post_type !== 'sfwd-quiz') {
    return; }
  [...]
  $quiz_id = $post->ID;
  $temp = get_post_meta($quiz_id, '_sfwd-quiz');
  [...]
}
add_action('transition_post_status', 'add_quiz_shortcode', 10, 3);

This is my code. But the hook seems to be not the right one, variable $temp contains no meta data.

Is there any way to get meta data of a post on publishing?

I have tried different hooks ('transition_post_status', 'save_post', ...) but no meta information were available.

Thanks in advance.

  • What have you actually coded and tested? Please post your code. – Brad Dalton Aug 2 '15 at 15:42
  • Please do not use multiple accounts. Please merge all your accounts into one account. – Pieter Goosen Aug 3 '15 at 9:27

Browse other questions tagged or ask your own question.