douzhaxian1267 2013-04-05 12:38
浏览 160
已采纳

如何在标准PHP页面中使用短代码?

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.

  • 写回答

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.

    http://codex.wordpress.org/Shortcode_API

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀