本文整理汇总了PHP中wp_get_post_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_post_terms函数的具体用法?PHP wp_get_post_terms怎么用?PHP wp_get_post_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_post_terms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: bootstrap_breadcrumbs
/**
* Add breadcrumbs functionality to your WordPress theme
*
* Once you have included the function in your functions.php file
* you can then place the following anywhere in your theme templates
* if(function_exists('bootstrap_breadcrumbs')) bootstrap_breadcrumbs();
*
* credit to: c.bavota - http://bavotasan.com (thanks for the code start)
*/
function bootstrap_breadcrumbs()
{
echo '<ol class="breadcrumb">';
echo '<li><a href="' . home_url('/') . '">Home</a></li>';
// are we at "blog home"?
if (is_home()) {
echo '<li><a href="#">Blogs</a></li>';
}
// where else do we want breadcrumbs
if (!is_page_template('pt-home.php') && !is_home()) {
// check if we're in a commerce plugin
if (function_exists('is_woocommerce') && is_woocommerce()) {
echo '<li><a href="/publications/order/">Shop</a></li>';
$product_cats = wp_get_post_terms(get_the_ID(), 'product_cat');
echo '<li><a href="/publications/order/' . str_replace(" ", "-", $product_cats[0]->name) . '">' . $product_cats[0]->name . '</a></li>';
}
// breadcrumb wordpress structures
if (is_category() || is_single() || is_single('aof')) {
if (get_the_category()) {
$category = get_the_category();
echo '<li><a href="/blog/category/' . str_replace(" ", "-", $category[0]->cat_name) . '">' . $category[0]->cat_name . '</a></li>';
}
if (is_single()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
}
echo '</ol>';
}
开发者ID:ethicalux,项目名称:kairos_eux,代码行数:44,代码来源:wp_bootstrap_breadcrumbs.php
示例2: set_defaults
public static function set_defaults($defaults, $form_type)
{
global $post;
$modules = FLBuilderModel::$modules;
$all_fields = self::find_fields($modules, 'defaults');
if (is_array($all_fields)) {
foreach ($all_fields as $parent_form => $types) {
foreach ($types as $type => $fields) {
foreach ($fields as $field => $default) {
if ($parent_form == $form_type) {
if ($type == 'meta') {
$defaults->{$field} = get_post_meta($post->ID, $default['key'], true);
}
if ($type == 'taxonomy') {
$defaults->{$field} = wp_get_post_terms($post->ID, $default['key'], array("fields" => "ids"));
}
if ($type == 'wp_option') {
$defaults->{$field} = get_option($default['key']);
}
}
}
}
}
}
return $defaults;
}
开发者ID:ZestSMS,项目名称:ZestSMS-Builder,代码行数:26,代码来源:class-zestsms-builder.php
示例3: rwmb_meta
/**
* Get post meta
*
* @param string $key Meta key. Required.
* @param int|null $post_id Post ID. null for current post. Optional
* @param array $args Array of arguments. Optional.
*
* @return mixed
*/
function rwmb_meta($key, $args = array(), $post_id = null)
{
$post_id = empty($post_id) ? get_the_ID() : $post_id;
$args = wp_parse_args($args, array('type' => 'text'));
// Set 'multiple' for fields based on 'type'
$args['multiple'] = in_array($args['type'], array('checkbox_list', 'file', 'image', 'plupload_image', 'thickbox_image'));
$meta = get_post_meta($post_id, $key, !$args['multiple']);
// Get uploaded files info
if ('file' == $args['type']) {
if (is_array($meta) && !empty($meta)) {
$files = array();
foreach ($meta as $id) {
$files[$id] = rwmb_file_info($id);
}
$meta = $files;
}
} elseif (in_array($args['type'], array('image', 'plupload_image', 'thickbox_image'))) {
if (is_array($meta) && !empty($meta)) {
global $wpdb;
$meta = implode(',', $meta);
// Re-arrange images with 'menu_order'
$meta = $wpdb->get_col("\n\t\t\t\tSELECT ID FROM {$wpdb->posts}\n\t\t\t\tWHERE post_type = 'attachment'\n\t\t\t\tAND ID in ({$meta})\n\t\t\t\tORDER BY menu_order ASC\n\t\t\t");
$images = array();
foreach ($meta as $id) {
$images[$id] = rwmb_image_info($id, $args);
}
$meta = $images;
}
} elseif ('taxonomy' == $args['type']) {
$meta = emtpy($args['taxonomy']) ? array() : wp_get_post_terms($post_id, $args['taxonomy']);
}
return $meta;
}
开发者ID:rosswintle,项目名称:meta-box,代码行数:42,代码来源:helpers.php
示例4: get_product_addons
/**
* Gets addons assigned to a product by ID
*
* @param int $post_id ID of the product to get addons for
* @param string $prefix for addon field names. Defaults to postid-
* @param bool $inc_parent Set to false to not include parent product addons.
* @param bool $inc_global Set to false to not include global addons.
* @return array array of addons
*/
function get_product_addons($post_id, $prefix = false, $inc_parent = true, $inc_global = true)
{
if (!$post_id) {
return array();
}
$addons = array();
$raw_addons = array();
$product_terms = apply_filters('get_product_addons_product_terms', wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids')), $post_id);
$exclude = get_post_meta($post_id, '_product_addons_exclude_global', true);
// Product Parent Level Addons
if ($inc_parent && ($parent_id = wp_get_post_parent_id($post_id))) {
$raw_addons[10]['parent'] = apply_filters('get_parent_product_addons_fields', get_product_addons($parent_id, $parent_id . '-', false, false), $post_id, $parent_id);
}
// Product Level Addons
$raw_addons[10]['product'] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($post_id, '_product_addons', true)), $post_id);
// Global level addons (all products)
if ('1' !== $exclude && $inc_global) {
$args = array('posts_per_page' => -1, 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_key' => '_priority', 'post_type' => 'global_product_addon', 'post_status' => 'publish', 'suppress_filters' => true, 'meta_query' => array(array('key' => '_all_products', 'value' => '1')));
$global_addons = get_posts($args);
if ($global_addons) {
foreach ($global_addons as $global_addon) {
$priority = get_post_meta($global_addon->ID, '_priority', true);
$raw_addons[$priority][$global_addon->ID] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($global_addon->ID, '_product_addons', true)), $global_addon->ID);
}
}
// Global level addons (categories)
if ($product_terms) {
$args = apply_filters('get_product_addons_global_query_args', array('posts_per_page' => -1, 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_key' => '_priority', 'post_type' => 'global_product_addon', 'post_status' => 'publish', 'suppress_filters' => true, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_terms, 'include_children' => false))), $product_terms);
$global_addons = get_posts($args);
if ($global_addons) {
foreach ($global_addons as $global_addon) {
$priority = get_post_meta($global_addon->ID, '_priority', true);
$raw_addons[$priority][$global_addon->ID] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($global_addon->ID, '_product_addons', true)), $global_addon->ID);
}
}
}
}
ksort($raw_addons);
foreach ($raw_addons as $addon_group) {
if ($addon_group) {
foreach ($addon_group as $addon) {
$addons = array_merge($addons, $addon);
}
}
}
// Generate field names with unqiue prefixes
if (!$prefix) {
$prefix = apply_filters('product_addons_field_prefix', "{$post_id}-", $post_id);
}
foreach ($addons as $addon_key => $addon) {
if (empty($addon['name'])) {
unset($addons[$addon_key]);
continue;
}
if (empty($addons[$addon_key]['field-name'])) {
$addons[$addon_key]['field-name'] = sanitize_title($prefix . $addon['name']);
}
}
return apply_filters('get_product_addons', $addons);
}
开发者ID:pcuervo,项目名称:ur-imprint,代码行数:69,代码来源:woocommerce-product-addons.php
示例5: start_el
public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
{
/** This filter is documented in wp-includes/category-template.php */
$cat_name = apply_filters('list_cats', esc_attr($category->name), $category);
// Don't generate an element if the category name is empty.
if (!$cat_name) {
return;
}
$args = array('post_type' => 'document_lists', 'tax_query' => array(array('taxonomy' => 'pages', 'field' => 'id', 'terms' => $category->term_id, 'include_children' => 1)));
$query = new WP_Query($args);
// The Loop
if ($query->have_posts()) {
$output .= '
<li class="list-headings">
<h2>' . $cat_name . '</h2>
';
while ($query->have_posts()) {
$query->the_post();
$post_id = get_the_ID();
$terms = wp_get_post_terms($post_id, 'pages');
$post_term_id = $terms[0]->term_id;
if ($post_term_id == $category->term_id) {
$link = '
<h3>
</h3>
';
$output .= "{$link}";
}
}
$output .= '';
}
// Restore original Post Data
wp_reset_postdata();
}
开发者ID:CityOfPrescott,项目名称:tabula-rasa_city-of-prescott,代码行数:35,代码来源:_document_lists.php
示例6: map_story_basics
/**
* Return story object with properties taken from ACF Fields.
*
* @since 0.1.0
* @access public
*
* @param object $this->container Newly instantiated Story class object.
* @param object $post Story post object.
**/
public function map_story_basics()
{
// Retrieve post_id variable.
$post_id = $this->container->post_id;
// Map ACF variables.
$acf_intro = get_post_meta($post_id, 'editorial_intro', true);
$acf_language = wp_get_post_terms($post_id, 'language', true);
$acf_category = wp_get_post_terms($post_id, 'category', true);
$acf_has_cta = get_post_meta($post_id, 'has_cta', true);
// Set editorial introduction.
if (!empty($acf_intro)) {
$this->set_editorial_intro($acf_intro);
}
// Set language.
if (!empty($acf_language) && 'WP_Term' === get_class($acf_language[0])) {
$this->container->language = $acf_language[0];
}
// Set category.
if (!empty($acf_category) && 'WP_Term' === get_class($acf_category[0])) {
$this->container->category = $acf_category[0];
}
// Set CTA check
if (!empty($acf_has_cta)) {
$this->container->has_cta = $acf_has_cta;
}
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:35,代码来源:class-controller-story.php
示例7: bbconnect_inbound_query
function bbconnect_inbound_query()
{
$bbc_inbound = new WP_Query(array('post_type' => apply_filters('bbconnect_inbound_posts', array('bb_note')), 'post_status' => array('publish', 'private'), 'posts_per_page' => apply_filters('bbconnect_inbound_per_page', -1), 'meta_query' => array(array('key' => '_bbc_action_status', 'value' => 'archived', 'compare' => 'NOT EXISTS'))));
$inbound = array();
if ($bbc_inbound->have_posts()) {
while ($bbc_inbound->have_posts()) {
$bbc_inbound->the_post();
global $post;
// GET THE TYPE
$type = apply_filters('bbconnect_inbound_type', '');
$type_label = apply_filters('bbconnect_inbound_type_label', '');
if ('bb_note' == $post->post_type) {
$terms = wp_get_post_terms($post->ID, 'bb_note_type');
if (count($terms) > 0) {
$term = $types[0];
$type = $term->term_slug;
$type_label = $term->term_name;
} else {
continue;
}
}
$user = get_userdata($post->post_author);
if (!$user) {
continue;
}
$inbound[] = array('ID' => $post->ID, 'uid' => $user->ID, 'name' => $user->first_name . ' ' . $user->last_name, 'email' => $user->user_email, 'avatar' => get_avatar($user->user_email, 32), 'website' => $user->user_url, 'title' => $post->post_title, 'content' => $post->post_content, 'date' => $post->post_date, 'type' => $type, 'type_label' => $type_label);
}
}
return $inbound;
}
开发者ID:whatthefork,项目名称:bbconnect,代码行数:30,代码来源:bbconnectpanels-incoming.php
示例8: worklist
/**
* print the filter for the portfolio
*
* @param array $args [description]
* @return [type] [description]
*/
private function worklist()
{
// TODO: get_query_var( 'paged' ) is given by codex, but not working in this case?
$paged = get_query_var('page') ? get_query_var('page') : 1;
$portfolio_query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $this->settings['limit'] ? $this->settings['limit'] : -1, 'paged' => $paged, 'meta_key' => '_thumbnail_id'));
if ($portfolio_query->have_posts()) {
echo '<div class="portfolio-list">';
$i = 1;
while ($portfolio_query->have_posts()) {
$portfolio_query->the_post();
$data_class = '';
$terms = wp_get_post_terms(get_the_ID(), 'portfolio_category', array('fields' => 'all'));
foreach ($terms as $term) {
$data_class .= $term->slug . ' ';
}
echo '<div data-id="' . $i . '" class="item preview-box ' . $data_class . '">';
$preview_args = array('src' => false, 'width' => $this->settings['img_width'], 'height' => $this->settings['img_height'], 'crop' => true, 'effect' => $this->settings['effect'], 'module' => 'portfolio');
echo inferno_preview($preview_args);
echo '</div>';
$i++;
}
echo '<div class="clear clearfix"></div>';
echo '</div>';
if ($this->settings['paginate'] == true) {
echo '<div class="pagination">';
echo '<div class="next">';
next_posts_link(__('Older entries', 'inferno'), $portfolio_query->max_num_pages);
echo '</div><div class="prev">';
previous_posts_link(__('Newer entries', 'inferno'));
echo '</div>';
echo '</div>';
}
}
wp_reset_postdata();
}
开发者ID:mladen,项目名称:Inferno,代码行数:41,代码来源:class-portfolio.php
示例9: bl_ajax_get_listings
function bl_ajax_get_listings()
{
/*
ob_start();
include(plugin_dir_path( __FILE__ )."templates/ajax-single-listing.php");
return trim( ob_get_clean() );
*/
$post_id = is_numeric($_POST["bl_post_id"]) ? $_POST["bl_post_id"] : false;
if ($post_id) {
$the_query = new WP_Query(array("post_type" => "bepro_listings", 'p' => $post_id));
while ($the_query->have_posts()) {
$the_query->the_post();
ob_start();
echo '<div id="shortcode_list">';
echo result_page_back_button();
include plugin_dir_path(__FILE__) . "/templates/content-single-listing.php";
$data = ob_get_contents();
ob_clean();
}
$post = get_post($post_id);
$_POST["l_name"] = $post->post_title;
$cats = get_terms(array('bepro_listing_types'), array('post_id' => $post_id));
$cats = wp_get_post_terms($post_id, "bepro_listing_types", array("fields" => "ids"));
$term = array();
foreach ($cats as $cat) {
$term[] = $cat;
}
$_POST["l_type"] = $term;
$_REQUEST["l_type"] = $term;
} else {
$data = "something went wrong";
}
return $data;
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:34,代码来源:bepro_listings_frontend.php
示例10: kad_portfolio_permalink
function kad_portfolio_permalink($permalink, $post_id, $leavename)
{
$post = get_post($post_id);
$rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%');
if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft'))) {
$unixtime = strtotime($post->post_date);
$category = '';
if (strpos($permalink, '%category%') !== false) {
$cats = wp_get_post_terms($post->ID, 'portfolio-type', array('orderby' => 'parent', 'order' => 'DESC'));
if ($cats) {
//usort($cats, '_usort_terms_by_ID'); // order by ID
$category = $cats[0]->slug;
}
// show default category in permalinks, without
// having to assign it explicitly
if (empty($category)) {
$category = 'portfolio-category';
}
}
$author = '';
if (strpos($permalink, '%author%') !== false) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
}
$date = explode(" ", date('Y m d H i s', $unixtime));
$rewritereplace = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name);
$permalink = str_replace($rewritecode, $rewritereplace, $permalink);
} else {
// if they're not using the fancy permalink option
}
return $permalink;
}
开发者ID:Kang8M,项目名称:gaonhat,代码行数:32,代码来源:post-types.php
示例11: get_fueltype
function get_fueltype($id)
{
$fueltype = wp_get_post_terms($id, 'occasion_fuel');
switch ($fueltype[0]->slug) {
case 'b':
echo 'Benzine';
break;
case 'd':
echo 'Diesel';
break;
case 'e':
echo 'Elektra';
break;
case 'g':
echo 'Gas';
break;
case 'h':
echo 'Hybride';
break;
default:
echo $fueltype[0]->name;
break;
}
unset($fueltype);
}
开发者ID:daanbakker1995,项目名称:lba-doorlinken-voorraad,代码行数:25,代码来源:util.fueltype.php
示例12: append_employee
private function append_employee(&$employees, $i, $id, $facilities = false, $dep_dropdown = false)
{
if ($facilities) {
$facility = get_field('employee-facility', $id);
if (!$facility) {
return false;
} else {
if (!in_array($facility->ID, $facilities)) {
return false;
}
}
}
if ($dep_dropdown) {
$departments = array();
$post_terms = wp_get_post_terms($id, 'department');
foreach ($post_terms as $term) {
array_push($departments, $term->name);
}
$employees[$i]['departments'] = $departments;
}
$employees[$i]['name'] = get_the_title($id);
$image = get_field('employee-image', $id);
$employees[$i]['image'] = $image['url'];
$employees[$i]['work_title'] = get_field('employee-jobtitle', $id);
$employees[$i]['email'] = get_field('employee-email', $id);
$employees[$i]['hide-email'] = get_field('employee-email-hide', $id);
$employees[$i]['text'] = get_field('employee-textarea', $id);
$phonenumbers = get_field('employee-phonenumbers', $id);
if (!empty($phonenumbers)) {
$employees[$i]['phone'] = $phonenumbers[0]['employee-phonenumber-number'];
}
}
开发者ID:sebjon-bytbil,项目名称:BB.CMS,代码行数:32,代码来源:staff.php
示例13: metabox_information
public function metabox_information($post)
{
wp_enqueue_style('markoheijnen-events', plugins_url('styles.css', __FILE__));
wp_nonce_field(plugin_basename(__FILE__), 'metabox_information_nonce');
$types = wp_get_post_terms($post->ID, 'event-type', array('fields' => 'names'));
$possible_types = array('heart' => 'liked-it', 'megaphone' => 'speaker', 'groups' => 'organizer', 'wordpress' => 'wordpress');
?>
<div class="event-types">
<?php
foreach ($possible_types as $icon => $term_slug) {
$checked = in_array($term_slug, $types) ? ' checked' : '';
?>
<label>
<input type="checkbox" autocomplete="off" name="eventtypes[<?php
echo $term_slug;
?>
]"<?php
echo $checked;
?>
>
<span class="dashicons dashicons-<?php
echo $icon;
?>
"></span>
</label>
<?php
}
?>
</div>
<?php
}
开发者ID:markoheijnen,项目名称:WP-Events,代码行数:35,代码来源:cpt.php
示例14: thuoctinh
function thuoctinh($name)
{
global $post;
$attribute_name = 'pa_' . $name;
//array( 'pa_nhan-hieu', 'pa_kich-co' , ); // Insert attribute names here
//foreach ( $attribute_names as $attribute_name ) {
$taxonomy = get_taxonomy($attribute_name);
if ($taxonomy && !is_wp_error($taxonomy)) {
$terms = wp_get_post_terms($post->ID, $attribute_name);
$terms_array = array();
if (!empty($terms)) {
foreach ($terms as $term) {
$archive_link = get_term_link($term->slug, $attribute_name);
if ($attribute_name == "pa_brand") {
if (is_single()) {
$full_line = '<a href="' . $archive_link . '">' . $term->name . '</a>';
} else {
$full_line = '<a href="' . $archive_link . '">' . $term->name . '</a>';
}
} else {
$full_line = '<a href="' . $archive_link . '">' . $term->name . '</a>';
}
array_push($terms_array, $full_line);
}
return implode($terms_array, ', ');
}
}
//}
}
开发者ID:Nguyenkain,项目名称:hanghieusales,代码行数:29,代码来源:functions.php
示例15: sell_media_set_default_terms
/**
* Set Default Terms
* Used in attachment-functions.php
*
* @since 0.1
*/
function sell_media_set_default_terms($post_id, $post = null, $term_ids = null)
{
if (is_null($post)) {
$post_type = get_post_type($post_id);
} else {
$post_type = $post->post_type;
$post_status = $post->post_status;
}
if (empty($post_status)) {
return;
}
if (empty($term_ids) || $term_ids === true) {
$term_ids = sell_media_get_default_terms();
}
$taxonomy = 'licenses';
$default_terms = array();
foreach ($term_ids as $term_id) {
$tmp_term_id = get_term_by('id', $term_id, $taxonomy);
if ($tmp_term_id) {
$default_terms[] = (int) $tmp_term_id->term_id;
$default_terms[] = (int) $tmp_term_id->parent;
}
}
$defaults = array($taxonomy => $default_terms);
$taxonomies = get_object_taxonomies($post_type);
foreach ((array) $taxonomies as $taxonomy) {
$terms = wp_get_post_terms($post_id, $taxonomy);
if (empty($terms) && array_key_exists($taxonomy, $defaults)) {
wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy);
}
}
}
开发者ID:rickalday,项目名称:Sell-Media,代码行数:38,代码来源:term-meta.php
示例16: outdoor_portfolio_item
function outdoor_portfolio_item()
{
$portfolio_id = isset($_POST['item_id']) ? intval($_POST['item_id']) : false;
if (!$portfolio_id) {
echo -1;
exit;
}
$return_data = array();
$portfolio = get_post($portfolio_id);
if ($portfolio) {
$return_data['title'] = $portfolio->post_title;
$return_data['description'] = $portfolio->post_content;
$portf_cats = wp_get_post_terms($portfolio->ID, 'portfolio-category', array('fields' => 'names'));
$portf_cats_str = is_array($portf_cats) ? implode(', ', $portf_cats) : '';
$portf_cats_str = trim($portf_cats_str, ',');
$return_data['category'] = $portf_cats_str;
$client = get_field('client', $portfolio_id) ? get_field('client', $portfolio_id) : '';
$link = get_field('link', $portfolio_id) ? get_field('link', $portfolio_id) : '';
$gallery = get_field('gallery', $portfolio_id) ? get_field('gallery', $portfolio_id) : '';
$return_data['client'] = $client;
$return_data['url'] = $link;
foreach ($gallery as $photo) {
$return_data['photos'][] = $photo['url'];
}
}
echo wp_json_encode($return_data, JSON_FORCE_OBJECT);
exit;
}
开发者ID:Akilan-i2i,项目名称:imaginator,代码行数:28,代码来源:ajax.php
示例17: fw_ext_portfolio_get_sort_classes
/**
* @param WP_Post[] $items
* @param array $categories
* @param string $prefix
*
* @return array
*/
function fw_ext_portfolio_get_sort_classes(array $items, array $categories, $prefix = 'category_')
{
$ext_portfolio_settings = fw()->extensions->get('portfolio')->get_settings();
$taxonomy = $ext_portfolio_settings['taxonomy_name'];
$classes = array();
$categories_classes = array();
foreach ($items as $key => $item) {
$class_name = '';
$terms = wp_get_post_terms($item->ID, $taxonomy);
foreach ($terms as $term) {
foreach ($categories as $category) {
if ($term->term_id == $category->term_id) {
$class_name .= $prefix . $category->term_id . ' ';
$categories_classes[$term->term_id] = true;
} else {
if (in_array($term->term_id, $category->children, true)) {
$class_name .= $prefix . $category->term_id . ' ';
$categories_classes[$term->term_id] = true;
}
}
$classes[$item->ID] = $class_name;
}
}
}
return $classes;
}
开发者ID:northpen,项目名称:northpen,代码行数:33,代码来源:helpers.php
示例18: get_related
/**
* Get related post ids
*
* @param int $post_id
*
* @return array Post ids
*/
function get_related($post_id)
{
$related = array();
$taxonomies = get_object_taxonomies($this->post->post_type);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy) {
$terms = wp_get_post_terms($this->post->ID, $taxonomy);
if ($terms) {
foreach ($terms as $term) {
$posts = new WP_Query(wp_parse_args(array('posts_per_page' => '-1', 'tax_query' => array(array('taxonomy' => $taxonomy, 'terms' => $term->slug, 'field' => 'slug'))), $this->args));
if ($posts->have_posts()) {
while ($posts->have_posts()) {
$posts->the_post();
if (!isset($related[get_the_ID()])) {
$related[get_the_ID()] = 0;
}
$related[get_the_ID()] += 1;
}
}
wp_reset_postdata();
}
}
}
}
//Put them in the right order and chop off what we don't need
asort($related);
$related = array_reverse($related, true);
if ($this->args['posts_per_page'] != -1) {
$related = array_chunk($related, $this->args['posts_per_page'], true);
} else {
$related = array($related);
}
return isset($related[0]) ? array_keys($related[0]) : array();
}
开发者ID:trendwerk,项目名称:related,代码行数:41,代码来源:class-tp-related.php
示例19: fw_theme_portfolio_post_taxonomies
/**
* return portfolio post taxonomies
*/
function fw_theme_portfolio_post_taxonomies($post_id, $return = false)
{
$taxonomy = 'fw-portfolio-category';
$terms = wp_get_post_terms($post_id, $taxonomy);
$list = '';
$checked = false;
foreach ($terms as $term) {
if ($term->parent == 0) {
/* if is checked parent category */
$list .= $term->slug . ', ';
$checked = true;
} else {
$list .= $term->slug . ', ';
$parent_id = $term->parent;
}
}
if (!$checked) {
/* if is not checked parent category extract this parent */
$term = get_term_by('id', $parent_id, $taxonomy);
$list .= $term->slug . ', ';
}
if ($return) {
return $list;
} else {
echo $list;
}
}
开发者ID:setcomunicacao,项目名称:setdigital,代码行数:30,代码来源:helpers.php
示例20: getFeaturesFiltered
public static function getFeaturesFiltered($params)
{
// Do not use self
unset($params['feature']);
$params['all'] = true;
$properties = self::getFiltered($params);
$all_features = self::getAllFeatures();
$nulled = false;
if (empty($all_features)) {
return $all_features;
}
foreach ($all_features as $key => $feature) {
$all_features[$key]->count = 0;
}
foreach ($properties as $property) {
$features = wp_get_post_terms($property->getId(), 'properties-features');
foreach ($all_features as $key => &$feature) {
foreach ($features as $local_key => $local_feature) {
if ($feature->slug == $local_feature->slug) {
$feature->count += 1;
}
}
}
}
foreach ($all_features as $key => $value) {
if ($all_features[$key]->count == 0) {
unset($all_features[$key]);
}
}
return $all_features;
}
开发者ID:pistonsky,项目名称:taivilla,代码行数:31,代码来源:propertiesmanager.class.php
注:本文中的wp_get_post_terms函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论