Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 未能使用代码美化插件_Wordpress - Fatal编程技术网

Wordpress 未能使用代码美化插件

Wordpress 未能使用代码美化插件,wordpress,Wordpress,我是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://schem

我是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>
下面是一个示例布局文件的片段。

我得到的结果是:


请告诉我哪里做错了。提前感谢。:)

您的意思是在WP编辑器或主题php文件中插入代码块

但是,首先需要将代码转换为html实体。对于exmaple:

在PHP中 '; ?> 在WP编辑器中
通过视觉模式粘贴代码,然后wp将在文本模式下自动将其转换为html实体。

根本原因是xml标记符号

更改为

将>更改为


这对我有用

我是在WP编辑器中完成的,但我真的需要添加一个php脚本吗?不,如果您只想在WP编辑器中插入代码,您不需要接触任何php。
<?php
$code = '<xml>...</xml>';

echo '<pre><code>';
echo htmlentities($code);
echo '</code></pre>';
?>