当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_get_post_parent_id函数代码示例

本文整理汇总了PHP中wp_get_post_parent_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_post_parent_id函数的具体用法?PHP wp_get_post_parent_id怎么用?PHP wp_get_post_parent_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_get_post_parent_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dbdb_body_classes

/**
 * Custom class for the WP 'body_class()' function
 * updated: 4/15/10
 */
function dbdb_body_classes($classes)
{
    // source http://darrinb.com/notes/2010/customizing-the-wordpress-body_class-function/
    global $post;
    global $wp_query;
    // if there is no parent ID and it's not a single post page, category page, or 404 page, give it
    // a class of "parent-page"
    if ($post->post_parent < 1 && !is_single() && !is_archive() && !is_404()) {
        $classes[] = 'parent-page';
    }
    // if the page/post has a parent, it's a child, give it a class of its parent name
    if ($post->post_parent > 0) {
        /* $parent_title = get_the_title($wp_query->post->post_parent);
           $parent_title = preg_replace('#\s#','-', $parent_title);
           $parent_title = strtolower($parent_title);
           $classes[] = 'parent-pagename-'.$parent_title; */
        $parent_id = wp_get_post_parent_id($wp_query->post);
        // $parent_id = get_the_ID($wp_query->post->post_parent);
        echo "PARENT ID : " . $parent_id;
        // $parent_id = preg_replace('#\s#','-', $parent_id);
        $parent_id = strtolower($parent_id);
        $classes[] = 'parent-id-' . $parent_id;
    }
    // add a class = to the name of post or page
    $classes[] = $wp_query->queried_object->post_name;
    return array_unique($classes);
}
开发者ID:aldelpech,项目名称:clea-atouts-c,代码行数:31,代码来源:functions.php

示例2: woocommerce_get_product_thumbnail

 function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $product;
     if ($product->is_type('variable')) {
         global $prdctfltr_global;
         $pf_activated = isset($prdctfltr_global['active_filters']) ? $prdctfltr_global['active_filters'] : array();
         if (!empty($pf_activated)) {
             $attrs = array();
             foreach ($pf_activated as $k => $v) {
                 if (substr($k, 0, 3) == 'pa_') {
                     $attrs = $attrs + array($k => $v[0]);
                 }
             }
             if (count($attrs) > 0) {
                 $curr_var = $product->get_available_variations();
                 foreach ($curr_var as $key => $var) {
                     $curr_var_set[$key]['attributes'] = $var['attributes'];
                     $curr_var_set[$key]['variation_id'] = $var['variation_id'];
                 }
                 $found = WC_Prdctfltr::prdctrfltr_search_array($curr_var_set, $attrs);
             }
         }
     }
     if (isset($found[0]) && $found[0]['variation_id'] && has_post_thumbnail($found[0]['variation_id'])) {
         $image = get_the_post_thumbnail($found[0]['variation_id'], $size);
     } elseif (has_post_thumbnail($product->id)) {
         $image = get_the_post_thumbnail($product->id, $size);
     } elseif (($parent_id = wp_get_post_parent_id($product->id)) && has_post_thumbnail($parent_id)) {
         $image = get_the_post_thumbnail($product, $size);
     } else {
         $image = wc_placeholder_img($size);
     }
     return $image;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:34,代码来源:pf-variable-override.php

示例3: applegate_get_top_bucket_parent

function applegate_get_top_bucket_parent($ID)
{
    if ($parent = wp_get_post_parent_id($ID)) {
        $ID = applegate_get_top_bucket_parent($parent);
    }
    return $ID;
}
开发者ID:realbig,项目名称:TH_APPLEGATE,代码行数:7,代码来源:bucket-menu.php

示例4: getpp_replace_hierarchicals

function getpp_replace_hierarchicals($value)
{
    $value = str_replace('this', get_the_ID(), $value);
    $value = str_replace('parent', wp_get_post_parent_id(get_the_ID()), $value);
    $value = str_replace('top', end(get_post_ancestors(get_the_ID())), $value);
    return $value;
}
开发者ID:bristweb,项目名称:codexcodes,代码行数:7,代码来源:index.php

示例5: 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

示例6: display_price_in_variation_option_name

function display_price_in_variation_option_name($term)
{
    global $wpdb, $product;
    $term_temp = $term;
    $term = strtolower($term);
    $term = str_replace(' ', '-', $term);
    $result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'");
    $term_slug = !empty($result) ? $result[0] : $term;
    $query = "SELECT postmeta.post_id AS product_id\nFROM {$wpdb->prefix}postmeta AS postmeta\nLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\nWHERE postmeta.meta_key LIKE 'attribute_%'\nAND postmeta.meta_value = '{$term_slug}'\nAND products.post_parent = {$product->id}";
    $variation_id = $wpdb->get_col($query);
    $parent = wp_get_post_parent_id($variation_id[0]);
    if ($parent > 0) {
        $_product = new WC_Product_Variation($variation_id[0]);
        $testVariable = $_product->get_variation_attributes();
        $itemPrice = strip_tags(woocommerce_price($_product->get_price()));
        $getPrice = $_product->get_price();
        $itemPriceInt = (int) $getPrice;
        $term = $term_temp;
        //this is where you can actually customize how the price is displayed
        if ($itemPriceInt > 0) {
            return $term . ' (' . $itemPrice . ' incl. GST)';
        } else {
            return $term . ' (' . $itemPrice . ')';
        }
    }
    return $term;
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:27,代码来源:woo-functions.php

示例7: shortcode_handler

 public function shortcode_handler($atts, $content = null, $tag = '')
 {
     $id = get_the_ID();
     $args = ['order' => 'ASC', 'orderby' => 'menu_order', 'post__not_in' => [$id], 'post_parent' => wp_get_post_parent_id($id), 'post_type' => get_post_type(), 'posts_per_page' => 20];
     $query = new WP_Query($args);
     $r = [];
     if ($query->have_posts()) {
         while ($query->have_posts()) {
             $query->the_post();
             $classes = ['hestia-sibling', 'hestia-wrap', sprintf('post-%s', esc_attr(get_the_ID()))];
             $has_thumbnail = has_post_thumbnail();
             $permalink = get_permalink();
             if ($has_thumbnail) {
                 // Because who doesn't love a properly alphabetized list?
                 array_unshift($classes, 'has-post-thumbnail');
             }
             $r[] = sprintf('<div class="%s">', implode(' ', $classes));
             $r[] = sprintf('<a href="%s">', esc_attr($permalink));
             if ($has_thumbnail) {
                 $r[] = get_the_post_thumbnail();
             }
             $r[] = get_the_title();
             $r[] = '</a>';
             $r[] = '</div>';
         }
     }
     wp_reset_postdata();
     return implode("\n", $r);
 }
开发者ID:ssnepenthe,项目名称:hestia,代码行数:29,代码来源:Siblings.php

示例8: getParentId

/**
 * Displays a list of pages which are either:
 * The children of the current page, or
 * The children of the parent page with a back to parent link
 */
function getParentId($pageId, $idsArray)
{
    $parentId = wp_get_post_parent_id($pageId);
    if ($parentId !== 0) {
        array_unshift($idsArray, $parentId);
        return getParentId($parentId, $idsArray);
    }
    return $idsArray;
}
开发者ID:mummybot,项目名称:tpbc,代码行数:14,代码来源:navigationSecondary.php

示例9: job_notification_templates

function job_notification_templates($post_id, $notification_receiver)
{
    // Applied job title
    $job_title = get_the_title($post_id);
    // Site URL
    $site_url = get_option('siteurl');
    $parent_id = wp_get_post_parent_id($post_id);
    $job_post_keys = get_post_custom_keys($parent_id);
    $applicant_post_keys = get_post_custom_keys($post_id);
    if (NULL != $job_post_keys) {
        if (in_array('jobfeature_company_name', $job_post_keys)) {
            $company_name = get_post_meta($parent_id, 'jobfeature_company_name', TRUE);
        }
    }
    if (NULL != $applicant_post_keys) {
        if (in_array('jobapp_name', $applicant_post_keys)) {
            $applicant_name = get_post_meta($post_id, 'jobapp_name', TRUE);
        }
    }
    if ('applicant' != $notification_receiver) {
        $message = '<div style="width:700px; margin:0 auto;  border: 1px solid #95B3D7;font-family:Arial;">' . '<div style="border: 1px solid #95B3D7; background-color:#95B3D7;">' . ' <h2 style="text-align:center;">Job Application </h2>' . ' </div>' . '<div  style="margin:10px;">' . '<p>' . date("Y/m/d") . '</p>' . '<p>';
        if (NULL != $notification_receiver) {
            $message .= 'Hi ' . $notification_receiver . ',';
        }
        $message .= '</p>' . '<p>I ';
        if (NULL != $applicant_name) {
            $message .= $applicant_name . '';
        }
        $message .= ',would like to apply for the post of ' . $job_title . ' at your company ';
        if (NULL != $company_name) {
            $message .= $company_name . '';
        }
        $message .= '.</p>' . '<p>I have gone through the application criterion and requirements for the particular job and have posted my resume at given address  ' . $site_url . '<br/>' . 'I have also filled the detail of the online application form on ' . date("Y/m/d") . '.' . '</p>' . '<p>I sincerely believe that my educational qualifications and extra-curricular activities will be appropriate for the job and the type of applicant it possible requires.' . 'I promiss to devote my heart and soul to the job once selected to serve your company ';
        if (NULL != $company_name) {
            $message .= $company_name . '';
        }
        $message .= '.</p>' . 'I will be extremely grateful if you kindly glance through my application and consider me for the interview and the adjacent processes.' . '</p>' . '<p>I will be eagerly looking forward to your reply mail.</p>' . '<p>Thank you</p>' . '<p>Sincerely,</p>';
        if (NULL != $applicant_name) {
            $message .= $applicant_name . '';
        }
        $message .= '</div>' . ' </div>';
    } else {
        $message = '<div style="width:700px; margin:0 auto;  border: 1px solid #95B3D7;font-family:Arial;">' . '<div style="border: 1px solid #95B3D7; background-color:#95B3D7;">' . ' <h2 style="text-align:center;">Job Application Acknowledgement</h2>' . ' </div>' . '<div  style="margin:10px;">' . '<p>' . date("Y/m/d") . '</p>' . '<p>';
        $message .= 'Hi ';
        if (NULL != $applicant_name) {
            $message .= '' . $applicant_name . ',';
        }
        $message .= '<p>Thank you for your interest in ';
        if (NULL != $company_name) {
            $message .= $company_name . '.';
        }
        $message .= 'We acknowledge receipt of your resume and application for a position ' . $job_title . ' and sincerely appreciate your interest in our company.' . '</p>' . '<p>We will screen all applicants and select candidates whose qualifications seem to meet our needs.' . ' We will carefully consider your application during the initial screening and will contact you if you are selected to continue in the recruitment process. ' . 'We wish you every success.</p>' . '<p>Regards,</p>' . '<p>Admin,</p>' . '<p>' . get_bloginfo('name') . '</p>';
        $message .= '</div>' . ' </div>';
    }
    return $message;
}
开发者ID:anurag-singh,项目名称:as-simple-job-board,代码行数:56,代码来源:simple-job-board-notification.php

示例10: storeCanastaAlCorteCliente

function storeCanastaAlCorteCliente($cliente, $variacion, $adicionales)
{
    $actualizacionID = getActualizacionCanasta($cliente->club_id);
    $producto = wp_get_post_parent_id($cliente->producto_id);
    $canasta = getIdCanastaClube($cliente->club_id, $producto);
    $actualizacionId = getIdActualizacionCanasta($cliente->club_id, $producto, $actualizacionID);
    $arr = ['cliente_id' => $cliente->cliente_id, 'saldo_anterior' => $cliente->saldo, 'costo_canasta' => $variacion->costoSemanal, 'variation_id' => $cliente->producto_id, 'club_id' => $cliente->club_id, 'adicionales' => serialize($adicionales), 'fecha_corte' => date('Y-m-d'), 'actualizacion_id' => $actualizacionId, 'canasta_id' => $canasta];
    saveCanastaAlCorteCliente($arr);
    destroyAdicionalesCliente($cliente->cliente_id, $adicionales);
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:10,代码来源:functions-update-canastas.php

示例11: wcj_get_product_image_url

 /**
  * wcj_get_product_image_url.
  *
  * @version 2.5.7
  * @since   2.5.7
  * @todo    placeholder
  */
 function wcj_get_product_image_url($product_id, $image_size = 'shop_thumbnail')
 {
     if (has_post_thumbnail($product_id)) {
         $image_url = get_the_post_thumbnail_url($product_id, $image_size);
     } elseif (($parent_id = wp_get_post_parent_id($product_id)) && has_post_thumbnail($parent_id)) {
         $image_url = get_the_post_thumbnail_url($parent_id, $image_size);
     } else {
         $image_url = '';
     }
     return $image_url;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:18,代码来源:wcj-functions.php

示例12: set_default_language

 public function set_default_language($post_id)
 {
     if (!$this->model->post->get_language($post_id)) {
         if (isset($_GET['new_lang']) && ($lang = $this->model->get_language($_GET['new_lang']))) {
             $this->model->post->set_language($post_id, $lang);
         } elseif (($parent_id = wp_get_post_parent_id($post_id)) && ($parent_lang = $this->model->post->get_language($parent_id))) {
             $this->model->post->set_language($post_id, $parent_lang);
         } else {
             $this->model->post->set_language($post_id, $this->pref_lang);
         }
     }
 }
开发者ID:iq007,项目名称:MadScape,代码行数:12,代码来源:admin-filters-post-base.php

示例13: meta

 /**
  * Get meta value
  *
  * @param int   $post_id
  * @param bool  $saved
  * @param array $field
  *
  * @return mixed
  */
 static function meta($post_id, $saved, $field)
 {
     $parent_id = wp_get_post_parent_id($post_id);
     if ($parent_id) {
         $post_id = $parent_id;
     }
     $options = $field['options'];
     $meta = wp_get_post_terms($post_id, $options['taxonomy']);
     $meta = is_array($meta) ? $meta : (array) $meta;
     $meta = wp_list_pluck($meta, 'term_id');
     return $meta;
 }
开发者ID:Juni4567,项目名称:mycashflow,代码行数:21,代码来源:class-wpp-taxonomy-inherited.php

示例14: getAncestors

 function getAncestors($post_id)
 {
     $a = array();
     while (true) {
         $parent = (int) wp_get_post_parent_id($post_id);
         if ($parent < 1) {
             break;
         }
         $post_id = $parent;
         $a[] = array('type' => 'post', 'id' => $post_id);
     }
     return $a;
 }
开发者ID:stevanbarry,项目名称:govsite,代码行数:13,代码来源:breadcrumbs.php

示例15: gpbbp_new_post

function gpbbp_new_post($post_id, $post, $update)
{
    $TOPIC_POST_TYPE = bbp_get_topic_post_type();
    $REPLY_POST_TYPE = bbp_get_reply_post_type();
    $post_type = get_post_type($post);
    $forum_id = NULL;
    if ($post_type == $TOPIC_POST_TYPE) {
        $forum_id = wp_get_post_parent_id($post_id);
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    if ($post_type == $REPLY_POST_TYPE) {
        $forum_id = bbp_get_forum_id();
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    gpbbp_new_post_notification($post_id, $post, $post_type);
}
开发者ID:petercorlettwiley,项目名称:bbPress-Groups-Sync-Plugin,代码行数:16,代码来源:gp-bbpress-groups.php


注:本文中的wp_get_post_parent_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。