有可能在wordpress上插件的选项页中做一个循环吗?
我在开发插件的过程中遇到了这个问题。 我必须循环浏览网站的所有页面,打印标题和ID。 当我做简单的循环时,它只是不打印任何东西 有没有办法在我的插件的选项中进行循环 找到了解决办法 我不知道插件选项页面中是否存在某种阻塞,但我们可以使用一小部分代码循环浏览每种自定义帖子类型:有可能在wordpress上插件的选项页中做一个循环吗?,wordpress,plugins,wordpress-theming,Wordpress,Plugins,Wordpress Theming,我在开发插件的过程中遇到了这个问题。 我必须循环浏览网站的所有页面,打印标题和ID。 当我做简单的循环时,它只是不打印任何东西 有没有办法在我的插件的选项中进行循环 找到了解决办法 我不知道插件选项页面中是否存在某种阻塞,但我们可以使用一小部分代码循环浏览每种自定义帖子类型: <?php //Search only for custom post type which is public. $args = array('public'=>true); /
<?php
//Search only for custom post type which is public.
$args = array('public'=>true);
//Get all custom post type name
$allMyCustomPostTypes = get_post_types($args);
foreach ($allMyCustomPostTypes as $myCustomPostType) {
//Create a filter for get_posts with every custom post type
$filter = array('numberposts' => 5, 'post_type' => $myCustomPostType);
//Pass the value to *get_posts*
$theposts = get_posts($filter);
foreach ($theposts as $thepost) {
//Easy print the name of the current post of the current custom post type
echo $thepost->post_title;
};
};
?>
我们在这里,希望这对某人有所帮助。您可以发布更多详细信息,比如您迄今为止尝试过的代码吗?您尝试过这个@Ashkar是的,我尝试过那个代码。这很有效,但不要做我必须做的事。这只适用于页面。我需要为每一个自定义的职位类型。这是我尝试过的简单循环