I want to modify the excerpt of a post automatically if a video has been inserted in a post either embedded or uploaded through media. So like the posts has a video on it, an excerpt is added like, "Please click to view video"

  • 1
    Keep in mind that if a user with a accessibility needs is using a screen reader, they usually browse via the hyperlinks, and they'll just hear a torrent of "Please click to view video please click to view video please click to view video etc etc" – Tom J Nowell Nov 8 '18 at 20:07
  • Okay well doesn't answer my question as to how to get the excerpt automatically there if there is a video in post? – Wali Muhammad Khubaib Nov 9 '18 at 4:26
  • Indeed, a comment isn't an answer! Can you be more specific about what you mean by a video in the post? Is it a youtube embed? Part of a custom field? Is it an attachment/media uploaded via the media library and attached to the post? Video post format? And why have you chosen to modify the excerpt rather than add code that changes behaviour? ( e.g. in the theme template don't show the excerpt but show X if it's a video ) – Tom J Nowell Nov 9 '18 at 14:55
  • Yes something like that only either I am able to modify excerpt or show X instead of video in template and by video I mean both either embedded by YouTube or any other source or uploaded through media – Wali Muhammad Khubaib Nov 10 '18 at 17:47
  • Oh so you don't know how to test if a post contains a video or not? And you're not using the video post format? Or a video tag? Or a post meta that labels them as containing a video? That complicates things. You might want to ask how to do that first – Tom J Nowell Nov 11 '18 at 3:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.