Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.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 post自定义字段的图像_Php_Wordpress_Random - Fatal编程技术网

Php 显示来自Wordpress post自定义字段的图像

Php 显示来自Wordpress post自定义字段的图像,php,wordpress,random,Php,Wordpress,Random,我正在使用下面的代码将随机帖子数据拉到我博客的边栏上。我如何添加从该帖子的自定义字段“athletethumbnail”中提取的图像? : 来自,在Posteta功能下 These functions are intended for use inside The Loop, and all return arrays. get_post_custom() Get all key/value data for the current post. ................ 解决方案:

我正在使用下面的代码将随机帖子数据拉到我博客的边栏上。我如何添加从该帖子的自定义字段“athletethumbnail”中提取的图像? :


来自,在Posteta功能下

These functions are intended for use inside The Loop, and all return arrays.

get_post_custom()
Get all key/value data for the current post.
................
解决方案:你应该使用

试试这个:

$custom = get_post_custom(the_ID());
echo $athletethumbnail = $custom["athletethumbnail"][0];
注意:您还应该能够在不传递POST ID的情况下离开,因为get\u POST\u自定义调用get\u没有传递POST ID

更改后:

    <?php
    global $wp_query;
    $current_id = $wp_query->get_queried_object_id();

        $my_query = new WP_Query( array(
            'post_type'=>'athletes',
            'posts_per_page'=>'1',
            'category' => '36' ,
            'orderby' =>'rand'
            ));

            // The Loop
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<?php 
 $custom = get_post_custom(the_ID());
 echo $athletethumbnail = $custom["athletethumbnail"][0];
 the_title(); ?>

<?php
      endwhile;

// Reset Post Data
wp_reset_postdata();

?>

  • 登录你的Facebook帐户

  • 在个人资料页面的搜索框中输入“Facebook开发者”。点击“Facebook.Developers.com”链接

  • 点击Facebook开发者菜单栏上的“我的应用”链接。您可能必须单击“允许”才能继续

  • 单击“开发者”页面右上角的“设置新应用”按钮

  • 在“应用程序名称”字段中输入新Facebook应用程序的名称。单击“同意”单选按钮选项接受“Facebook条款”,然后单击“创建应用程序”

  • 在“框中文本”字段中键入“安全检查”框中显示的文本,与屏幕上显示的文本完全相同。单击“提交”按钮

  • 在“说明”字段中输入新应用程序的说明。在“语言”下拉框中选择应用程序的默认语言。为“用户支持地址”选择“电子邮件”或“URL”选项。这是用户用于就Facebook应用程序的问题或支持问题与您联系的地址

  • 输入您的用户支持URL地址或电子邮件地址。输入隐私政策页面的URL地址。所有Facebook应用程序开发人员必须在其网站上显示隐私政策,说明应用程序收集和使用的Facebook用户信息的类型。如果您要求用户接受“服务条款”在使用应用程序之前,请在“服务条款URL”字段中输入包含协议文本的URL地址

  • 单击“保存更改”按钮。Facebook保存新应用程序的信息更改,并在下一页显示摘要信息。摘要页面在“应用程序ID”标题下显示新应用程序的Facebook应用程序ID。然后,您可以开始为新的Facebook应用程序编写代码


  • 你能帮我发布完整的代码吗?我似乎无法让它工作
        <?php
        global $wp_query;
        $current_id = $wp_query->get_queried_object_id();
    
            $my_query = new WP_Query( array(
                'post_type'=>'athletes',
                'posts_per_page'=>'1',
                'category' => '36' ,
                'orderby' =>'rand'
                ));
    
                // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
    <?php 
     $custom = get_post_custom(the_ID());
     echo $athletethumbnail = $custom["athletethumbnail"][0];
     the_title(); ?>
    
    <?php
          endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    
    ?>