我是WordPress的新手。
我正在尝试插入一个代码块在闪亮的主题的Wordpress。这是我在编辑器中的代码:
Following is a snippet of a sample Layout file.
<pre class="prettyprint">
<code class="xml">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This will print hello world" />
<!-- More GUI components go here -->
</LinearLayout>
</code></pre>我得到了这个作为输出:

请告诉我哪里做错了。提前感谢..:)
发布于 2017-08-21 14:59:08
根本原因是xml标记符号。
将<更改为<
Change > to >
这对我很有效!
发布于 2016-11-16 20:46:07
你的意思是在WP编辑器或主题php文件中插入代码块?
但是,您需要首先将代码转换为html实体。例如:
在PHP中
<?php
$code = '<xml>...</xml>';
echo '<pre><code>';
echo htmlentities($code);
echo '</code></pre>';
?>在WP编辑器中
粘贴你的代码通过可视化模式,然后wp将自动转换为文本模式下的html实体。
https://stackoverflow.com/questions/40615180
复制相似问题