首页 > 解决方案 > 如何将php代码信息发送到外部链接

问题描述

我正在使用以下代码来定义我的数据库数据中包含的某些信息,并将它们发送到外部动态页面。我目前能够成功发送我拥有的 4 个数据中的 3 个。帖子标题(1)、剧情(2)、海报(3)无问题发送;而快照(4)给我带来了麻烦。

$send 变量是将数据带到外部动态页面的变量。我认为我在其中调用“快照”的方式做错了什么。

$post_title = get_the_title();
$theplot = get_post_meta($post->ID, 'book_plot', true);
$poster_id = get_post_thumbnail_id();
$poster_src = wp_get_attachment_image_src($poster_id,'medium', true);

snapshot($post_id) {
global $post;
$thumbnail_ID = get_post_thumbnail_id();
$images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
if ($images) :
foreach ($images as $attachment_id => $image) :
if ( $image->ID != $thumbnail_ID ) :
$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); //alt
if ($img_alt == '') : $img_alt = $image->post_title; endif;
$big_array = image_downsize( $image->ID, 'large' );
$img_url = $big_array[0];
echo $img_url;
endif; endforeach; endif; }

$send = 'http://mywebsite.com/show/?title='. urlencode($post_title) . '&plot='. urlencode($theplot) . '&image='. ($poster_src[0]) . '&snapshot='. (snapshot("$post->ID"));

标签: phpwordpress

解决方案


推荐阅读