• Resolved garybultitude

    (@garybultitude)


    Hi, I can see from your plugin that if an image has not been uploaded to a post… the post can have an image, specific to the category it is in…

    I have tried adding the to my functions.php but it gives me an error, even before I upload it… Am I placing it in the wrong place?

    Kind regards

    Gary

    function dfi_category ( $dfi_id, $post_id ) {
      // all which have 'animals' as a category
      if ( has_category( 'animals', $post_id ) ) {
    
        //sub category
        if ( has_category( 'cats', $post_id ) ) {
          return 7; // cats img
        } else if has_category( 'dogs', $post_id ) {
          return 8; // dogs img
        }
    
        return 6; // default animals picture
      }
      return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_category', 10, 2 );

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

Viewing 1 replies (of 1 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    Hello Gary,

    There is a typo in the example code on the plugin page.
    I’ll have to fix that.

    For now this is the error:
    Wrong
    } else if has_category( 'dogs', $post_id ) {
    Correct
    } else if ( has_category( 'dogs', $post_id ) ) {

    Let me know how it goes.

    Jan-Willem

Viewing 1 replies (of 1 total)
  • The topic ‘When i place custom code’ is closed to new replies.