本文整理汇总了PHP中acf_get_post_title函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_get_post_title函数的具体用法?PHP acf_get_post_title怎么用?PHP acf_get_post_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_get_post_title函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acf_location_rules_values_page_grandparent
function acf_location_rules_values_page_grandparent($choices)
{
// this code is copied directly from
// render_location_values()
// case "page"
$groups = acf_get_grouped_posts(array('post_type' => 'page'));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
$posts = acf_extract_var($groups, $group_title);
foreach (array_keys($posts) as $post_id) {
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
$choices = $posts;
}
}
// end of copy from ACF
return $choices;
}
示例2: render_location_value
function render_location_value($options)
{
// vars
$options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null));
// vars
$choices = array();
// some case's have the same outcome
if ($options['param'] == "page_parent") {
$options['param'] = "page";
}
switch ($options['param']) {
/*
* Basic
*/
case "post_type":
// all post types except attachment
$exclude = array('attachment');
$choices = acf_get_post_types($exclude);
$choices = acf_get_pretty_post_types($choices);
break;
case "user_type":
global $wp_roles;
$choices = $wp_roles->get_names();
if (is_multisite()) {
$choices['super_admin'] = __('Super Admin');
}
break;
/*
* Post
*/
/*
* Post
*/
case "post":
// get post types
$exclude = array('page', 'attachment');
$post_types = acf_get_post_types($exclude);
// get posts grouped by post type
$groups = acf_get_posts(array('post_type' => $post_types));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices[$group_title] = $posts;
}
}
break;
case "post_category":
$terms = acf_get_taxonomy_terms('category');
if (!empty($terms)) {
$choices = array_pop($terms);
}
break;
case "post_format":
$choices = get_post_format_strings();
break;
case "post_status":
$choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
break;
case "post_taxonomy":
$choices = acf_get_taxonomy_terms();
// unset post_format
if (isset($choices['post_format'])) {
unset($choices['post_format']);
}
break;
/*
* Page
*/
/*
* Page
*/
case "page":
// get posts grouped by post type
$groups = acf_get_posts(array('post_type' => 'page'));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices = $posts;
}
}
break;
case "page_type":
$choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
break;
case "page_parent":
// refer to "page"
//.........这里部分代码省略.........
示例3: get_post_title
function get_post_title($post, $field, $post_id = 0)
{
// get post_id
if (!$post_id) {
$form_data = acf_get_setting('form_data');
if (!empty($form_data['post_id'])) {
$post_id = $form_data['post_id'];
} else {
$post_id = get_the_ID();
}
}
// vars
$title = acf_get_post_title($post);
// elements
if (!empty($field['elements'])) {
if (in_array('featured_image', $field['elements'])) {
$image = '';
if ($post->post_type == 'attachment') {
$image = wp_get_attachment_image($post->ID, array(17, 17));
} else {
$image = get_the_post_thumbnail($post->ID, array(17, 17));
}
$title = '<div class="thumbnail">' . $image . '</div>' . $title;
}
}
// filters
$title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'], $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $post_id);
// return
return $title;
}
示例4: get_post_title
function get_post_title($post, $field, $post_id = 0)
{
// get post_id
if (!$post_id) {
$form_data = acf_get_setting('form_data');
if (!empty($form_data['post_id'])) {
$post_id = $form_data['post_id'];
} else {
$post_id = get_the_ID();
}
}
// vars
$title = acf_get_post_title($post);
// filters
$title = apply_filters('acf/fields/page_link/result', $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/page_link/result/name=' . $field['_name'], $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/page_link/result/key=' . $field['key'], $title, $post, $field, $post_id);
// return
return $title;
}
示例5: get_post_title
function get_post_title($post, $field, $post_id = 0, $is_search = 0)
{
// get post_id
if (!$post_id) {
$post_id = acf_get_form_data('post_id');
}
// vars
$title = acf_get_post_title($post, $is_search);
// filters
$title = apply_filters('acf/fields/post_object/result', $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/post_object/result/name=' . $field['_name'], $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $post, $field, $post_id);
// return
return $title;
}
示例6: get_post_title
function get_post_title($post, $field, $post_id = 0, $is_search = 0)
{
// get post_id
if (!$post_id) {
$post_id = acf_get_form_data('post_id');
}
// vars
$title = acf_get_post_title($post, $is_search);
// featured_image
if (acf_in_array('featured_image', $field['elements'])) {
// vars
$class = 'thumbnail';
$thumbnail = acf_get_post_thumbnail($post->ID, array(17, 17));
// icon
if ($thumbnail['type'] == 'icon') {
$class .= ' -' . $thumbnail['type'];
}
// append
$title = '<div class="' . $class . '">' . $thumbnail['html'] . '</div>' . $title;
}
// filters
$title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'], $title, $post, $field, $post_id);
$title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $post_id);
// return
return $title;
}
示例7: render_location_value
function render_location_value($options)
{
// vars
$options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null));
// vars
$choices = array();
// some case's have the same outcome
if ($options['param'] == "page_parent") {
$options['param'] = "page";
}
switch ($options['param']) {
/*
* Post
*/
case "post_type":
// get post types
$post_types = acf_get_post_types(array('show_ui' => 1, 'exclude' => array('attachment')));
// get choices
$choices = acf_get_pretty_post_types($post_types);
// end
break;
case "post":
// get post types
$post_types = acf_get_post_types(array('exclude' => array('page', 'attachment')));
// get posts grouped by post type
$groups = acf_get_grouped_posts(array('post_type' => $post_types));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices[$group_title] = $posts;
}
}
break;
case "post_template":
// vars
$templates = wp_get_theme()->get_post_templates();
$default = apply_filters('default_page_template_title', __('Default Template', 'acf'));
// choices
$choices = array('default' => $default);
// templates
if (!empty($templates)) {
foreach ($templates as $post_type => $post_type_templates) {
$choices = array_merge($choices, $post_type_templates);
}
}
// break
break;
case "post_category":
$terms = acf_get_taxonomy_terms('category');
if (!empty($terms)) {
$choices = array_pop($terms);
}
break;
case "post_format":
$choices = get_post_format_strings();
break;
case "post_status":
global $wp_post_statuses;
if (!empty($wp_post_statuses)) {
foreach ($wp_post_statuses as $status) {
$choices[$status->name] = $status->label;
}
}
break;
case "post_taxonomy":
$choices = acf_get_taxonomy_terms();
// unset post_format
if (isset($choices['post_format'])) {
unset($choices['post_format']);
}
break;
/*
* Page
*/
/*
* Page
*/
case "page":
// get posts grouped by post type
$groups = acf_get_grouped_posts(array('post_type' => 'page'));
if (!empty($groups)) {
foreach (array_keys($groups) as $group_title) {
// vars
$posts = acf_extract_var($groups, $group_title);
// override post data
foreach (array_keys($posts) as $post_id) {
// update
$posts[$post_id] = acf_get_post_title($posts[$post_id]);
}
// append to $choices
$choices = $posts;
}
}
//.........这里部分代码省略.........