Getting the following php error when trying to add a new post:

Warning: array_pop() expects parameter 1 to be array, boolean given in /home/mysite/public_html/blog/wp-content/themes/mytheme/functions.php on line 675

Here is the function:

function glossary_term_permalink($post_link, $post, $leavename, $sample) {
    if (false !== strpos($post_link, '%recipe_cat%')) {
        $glossary_letter = get_the_terms($post->ID, 'recipe_cat');
        $post_link = str_replace('%recipe_cat%', array_pop($glossary_letter)->slug, $post_link);
    return $post_link;

Any idea what the issue is and how to resolve?


1 Answer 1


get_the_terms() will return a boolean false under some circumstances:

A post with no terms assigned gives a false result, not an empty array.


It sounds like that is what is happening. You need to check that $post_link = to ensure that it is the type you expect before trying to use it.

  • How do you check $post_link =?
    – frshjb373
    Apr 2, 2015 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.