2013-04-05 12:38
浏览 150


I want to use a Wordpress style shortcode in my own CMS. For example, with Embedded Tweets, I can say:

[tweet 'TWEET URL']

and the tweet will be embedded with the standard format as supplied by Twitter. Similarly with YouTube videos:

[youtube 'YOUTUBE VIDEO']

will embed the YouTube video player. How would I do that with PHP and MySQL? I am not looking for a 'generic' system; manually adding shortcodes would work just fine with me, as long as I know what I am doing.

图片转代码服务由CSDN问答提供 功能建议

我想在自己的CMS中使用Wordpress样式的短代码。 例如,使用嵌入式推文,我可以说:

[tweet'TWEET URL']

和推文 将嵌入Twitter提供的标准格式。 与YouTube视频类似:

[youtube'YOUTUBE VIDEO']

将嵌入YouTube视频播放器。 我如何用PHP和MySQL做到这一点? 我不是在寻找一个“通用”系统; 只要我知道自己在做什么,手动添加短代码对我来说就可以了。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongwuqi4243 2013-04-05 12:43

    WordPress has a fairly elaborate scheme for processing post/page content in the dbms and depositing it in the output stream. Part of that involves scanning the text for registered shortcodes and replacing them with the appropriate URLs or other text.

    The WordPress Codex explains how to write a plugin to implement a shortcode. There are plenty of examples to look at.

    But if you're going to immplement this in your own CMS you need to build your own scheme for processing content, and tie processing into it.

    解决 无用
    打赏 举报

相关推荐 更多相似问题