Wordpress / ACF:与作者相关的帖子

时间:2016-03-29 13:45:38

标签: php wordpress advanced-custom-fields

我需要在个人资料页面上的wp-admin列表中列出所有用户帖子。不仅仅是post_type post,还有author和当前用户ID。

我已将关联商店设置为post_type,但是不可能再制作某种类型的“元查询”,所以我只能选择显示当前用户的帖子?

1 个答案:

答案 0 :(得分:0)

答案是创建ACF relationshop query

////// Make Template archive object
$templateArchive = new ZipArchive();
$templateArchive->open(PATH_TO_TEMPLATES.'_files/'.$templateName.'/_pack/'.$templateName.'.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);

$files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($templateDir."/templates/".$template_archive_name),
    RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file)
{

    // Skip directories (they would be added automatically)
    if (!$file->isDir())
    {
        // Get real and relative path for current file
        $filePath = $file->getRealPath();

        // relative path is full path, reduced with length of templateDir string and 11 more chars for /templates/
        $relativePath = substr($filePath, strlen($templateDir) + 11);

        // Add current file to archive
        $templateArchive->addFile($filePath, $relativePath);
    }
}

// Template Zip archive will be created only after closing object
$templateArchive->close();

并将其添加到_.each(data, function(item) { _.extend(item, {name: item.first}); });