Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.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
Php 如何为最近的帖子编写Wordpress短代码_Php_Wordpress - Fatal编程技术网

Php 如何为最近的帖子编写Wordpress短代码

Php 如何为最近的帖子编写Wordpress短代码,php,wordpress,Php,Wordpress,我想为最近的文章创建一个简单的Wordpress短代码,以便在文章中使用它 我知道创建短代码的基本步骤: 1-我打开WP主题“functions.php”文件,并包含在同一目录中创建的新自定义文件,我将其命名为“custom shortcode.php” 2-在“custom shortcode.php”中,我编写了实际的代码: <?php // Shortcode function function custom_shortcode() { //

我想为最近的文章创建一个简单的Wordpress短代码,以便在文章中使用它

我知道创建短代码的基本步骤:

1-我打开WP主题“functions.php”文件,并包含在同一目录中创建的新自定义文件,我将其命名为“custom shortcode.php”

2-在“custom shortcode.php”中,我编写了实际的代码:

 <?php

     // Shortcode function
    function custom_shortcode() {

        // Use WP recent posts function with default values return
        return php wp_get_recent_posts( $args, $output );
    }
    // Add shortcode (WP function)
    add_shortcode( 'recent-post', 'custom_shortcode' );


?>

我想使用可湿性粉剂默认功能获得最近的职位,是我的代码将工作? 我想用最少的代码和返回的默认值来获取短代码,这样我就可以集中精力学习如何制作自己的短代码。

使用
shortcode\u atts(数组(
用于定制样式.)

你可以跟着