如果你想在自定义 PHP 页面中检索 WordPress 照片的特定值,你可以使用 PHP 的函数来获取这些信息。

以下是一种可能的解决方案:

  1. 在你的自定义 PHP 页面中,使用 WP_Query 函数来获取相册或照片的信息。例如,如果你想获取特定相册中的照片,可以使用以下代码:
<?php
$args = array(
    'post_type' => 'attachment',
    'post_parent' => get_the_ID(),
    'posts_per_page' => -1,
);
$query = new WP_Query( $args );
?>

在上述代码中,'post_type' 参数指定要检索的内容类型为 'attachment','post_parent' 参数指定要检索的父帖子(即相册)的 ID。'posts_per_page' 参数指定要检索的照片数量(-1 表示检索所有照片)。

  1. 使用 WP_Query 函数的 get_posts 方法来获取照片的信息。例如,你可以使用以下代码来获取第一张照片的标题:
<?php
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) :
        $query->the_post();
        echo get_the_title();
    endwhile;
endif;
wp_reset_postdata();
?>

在上述代码中,'have_posts' 方法用于检查是否有照片可供检索。'the_post' 方法用于获取当前照片的信息。'get_the_title' 方法用于获取照片的标题。

请注意,上述代码假设你已经在自定义 PHP 页面中正确设置了 WP_Query 函数来检索相册或照片的信息。如果你的页面没有正确设置 WP_Query 函数,你可能会遇到错误。