在WordPress自定义帖子类型中创建默认内容

时间:2020-10-22 17:35:24

标签: wordpress

是否可以在insert_default_content函数中插入原始HTML,以将默认数据添加到内容字段中?当我尝试创建新帖子时,它不会显示该代码的HTML。

function insert_default_content($content) {
$content = "
All rights, including <em>this very important stuff here</em>, in the content of these web pages are owned or controlled for these purposes by the <strong>xyz blah blah corporation</strong>.<p style='color: red; font-size: 20px;'>This is my first paragraph.</p>
<canvas id='myCanvas' width='578' height='200'></canvas>
<script>
  var canvas = document.getElementById('myCanvas');
  var context = canvas.getContext('2d');
  context.beginPath();
  context.arc(288, 75, 70, 0, Math.PI, false);
  context.closePath();
  context.lineWidth = 5;
  context.fillStyle = 'red';
  context.fill();
  context.strokeStyle = '#550000';
  context.stroke();
</script>   
";
return $content;

未显示具有该形状的画布。我正在尝试使用基于画布的绘图工具来构建帖子类型。

0 个答案:

没有答案