小智 5
您可以制作一个短代码来包含该代码。您可以将 html 保存到文件并获取其内容,或者只是将代码复制并粘贴到短代码中。将如下内容添加到您的functions.php 文件中:
function get_my_bokeh() {
return file_get_contents( "http://www.example.com/path/to/bokeh.html" );
}
add_shortcode( 'print_bokeh', 'get_my_bokeh' );
Run Code Online (Sandbox Code Playgroud)
/* 或者 */
function get_my_bokeh() {
ob_start(); ?>
<!-- paste your HTML code here -->
<?php return ob_get_clean();
}
add_shortcode( 'print_bokeh', 'get_my_bokeh' );
Run Code Online (Sandbox Code Playgroud)
然后将短代码添加[print_bokeh]到文本编辑器。
在上面的两个示例中,您应该清除 构成整个 HTML 文档的所有<html> <head>&元素,只保留内容。<body>