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


PHP get_the_id函数代码示例

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


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

示例1: fpw_excerpt

/**
 * apply custom filters to the_excerpt in feature a page widget template
 *
 * @since 2.0.0
 */
function fpw_excerpt($excerpt)
{
    $post_id = get_the_id();
    /**
     * allow use of autogenerated excerpts
     *
     * by default, excerpt is empty if it is not explicitly set in the "Excerpt" field
     *
     * @since  2.0.0
     *
     * @param bool $fpw_auto_excerpt false by default
     * @return bool whether to allow auto-generated excerpts when excerpt is empty
     */
    $fpw_auto_excerpt = apply_filters('fpw_auto_excerpt', false);
    if (!has_excerpt() && !(bool) $fpw_auto_excerpt) {
        return;
    }
    /*$custom_excerpt = get_post_meta( $post_id, 'fpw_excerpt', true );
    	if( $custom_excerpt ) {
    		$excerpt = $custom_excerpt;
    	}*/
    /**
     * filter the_excerpt in feature a page widget
     *
     * @since  2.0.0
     *
     * @param   string 	$excerpt 	excerpt of post
     * @param   int 	$post_id 	post id
     * @return   string used as the excerpt
     */
    $excerpt = apply_filters('fpw_excerpt', $excerpt, $post_id);
    return $excerpt;
}
开发者ID:alphacityco,项目名称:kotobanokumo-wp-content,代码行数:38,代码来源:fpw_template_filters.php

示例2: salesforce_w2l_lead_source_example

function salesforce_w2l_lead_source_example($lead_source, $form_id)
{
    if ($form_id == 1) {
        return 'Example Lead Source for Form #1 on page id #' . get_the_id();
    }
    return $lead_source;
}
开发者ID:jiwicky,项目名称:salesforce-wordpress-to-lead,代码行数:7,代码来源:examples.php

示例3: rum_post_cta_meta_box_list

function rum_post_cta_meta_box_list()
{
    global $post;
    // store global post object for later resetting after our query
    // using wp_reset_postdata() doesn't work so we are manually resetting the global
    $post_old = $post;
    // initialize variables
    $options = '';
    // get plugin option array and store in a variable
    $plugin_option_array = get_option('rum_post_cta_plugin_options');
    // fetch values from the plugin option variable array
    $post_cta_post_type = $plugin_option_array['post_type'];
    // retrieve the custom meta box value
    $post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
    // set query arguments
    $args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
    // execute the query
    $cta_post_query = new WP_Query($args);
    // The Loop
    while ($cta_post_query->have_posts()) {
        $cta_post_query->the_post();
        $post_title = get_the_title();
        $post_ID = get_the_id();
        $options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
    }
    // restore the global $post variable of the main query loop
    // wp_reset_postdata(); doesn't work so we are manually resetting it back
    // restore global post object
    $post = $post_old;
    setup_postdata($post);
    return $options;
}
开发者ID:rumspeed,项目名称:post-call-to-action,代码行数:32,代码来源:metabox.php

示例4: get_related_posts

function get_related_posts()
{
    // an array of tags from the current post
    $related_tags = get_the_tags();
    /*
    	$tag will be used in this example, this is just the first tag
    	from the array.  To optimize the plugin we would want to loop through
    	all of the tags in the $related_tags array and do something more
    	interesting with them.
    */
    $tag = $related_tags[0];
    // The ID of the current post
    $current_post = get_the_id();
    // The arguments for the nested loop
    $args = array('posts_per_page' => 3, 'post__not_in' => array($current_post), 'tag' => $tag->name);
    $related_query = new WP_Query($args);
    if ($related_query->have_posts()) {
        $html = '<h2>Some Related Posts</h2>';
        $html .= '<ul>';
        while ($related_query->have_posts()) {
            $related_query->the_post();
            $html .= '<li>';
            $html .= get_the_title();
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    return $html;
}
开发者ID:philwp,项目名称:wp-pitt-related,代码行数:29,代码来源:wp-pitt-related.php

示例5: friend_list_func

    public static function friend_list_func($atts, $content = "")
    {
        $atts = shortcode_atts(array('per_page' => '100'), $atts, 'friend_list');
        $return = "";
        query_posts(array('post_type' => 'friend', 'showposts' => $atts['per_page'], 'meta_query' => array('relation' => 'AND', array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif', 'compare' => 'NOT LIKE'), array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_female.gif', 'compare' => 'NOT LIKE'))));
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $displayName = get_post_meta(get_the_id(), 'displayName', true);
                $avatar = get_post_meta(get_the_id(), 'avatar150', true);
                $return .= sprintf('<div class="col-lg-3 col-sm-3 focus-box">
		 								<div class="service-icon">
		 									<i style="background:url(%s) no-repeat center;width:100%%; height:100%%;" class="pixeden"></i>
		 								</div>
		 								<h3 class="red-border-bottom">%s</h3>
		 								<a class="btn btn-primary btn-block green-btn btn-sm" href="https://www.fitbit.com/user/%s"><i class="fa fa-plus"></i> Add Friend</a>
		 								<br/>
		 							</div>', $avatar, $displayName, get_the_title(), get_the_content());
            }
            $return = '<div class="hwd-wrapper"><div class="row">' . $return . '</div></div>';
        } else {
            $return = 'No Friends Found';
        }
        wp_reset_query();
        return $return;
    }
开发者ID:HealthyWebDeveloper,项目名称:HWD-friend-finder,代码行数:26,代码来源:class-friend-shortcode.php

示例6: register

 /**
  * Register meta boxes related to `vr_agent` post type
  *
  * @param   array   $meta_boxes
  * @return  array   $meta_boxes
  * @since   1.0.0
  */
 public function register($meta_boxes)
 {
     $prefix = 'vr_agent_';
     $meta_boxes[] = array('id' => 'vr_agent_meta_box_details_id', 'title' => __('Contact Details', 'VRC'), 'post_types' => array('vr_agent'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('id' => "{$prefix}job_title", 'type' => 'text', 'name' => __('Job Title', 'VRC')), array('id' => "{$prefix}email", 'type' => 'email', 'name' => __('Email Address', 'VRC'), 'desc' => __("Agent related messages from contact form on rental details page, will be sent to this email address.", "VRC")), array('id' => "{$prefix}mobile_number", 'type' => 'text', 'name' => __('Mobile Number', 'VRC')), array('name' => __('Office Number', 'VRC'), 'id' => "{$prefix}office_number", 'type' => 'text'), array('id' => "{$prefix}fax_number", 'type' => 'text', 'name' => __('Fax Number', 'VRC')), array('id' => "{$prefix}office_address", 'type' => 'textarea', 'name' => __('Office Address', 'VRC')), array('id' => "{$prefix}summary", 'type' => 'textarea', 'name' => __('Profile Summary (Optional)', 'VRC')), array('id' => "{$prefix}fb_url", 'type' => 'url', 'name' => __('Facebook URL', 'VRC')), array('id' => "{$prefix}twt_url", 'type' => 'url', 'name' => __('Twitter URL', 'VRC')), array('id' => "{$prefix}gplus_url", 'type' => 'url', 'name' => __('Google Plus URL', 'VRC')), array('id' => "{$prefix}li_url", 'type' => 'text', 'name' => __('LinkedIn URL', 'VRC')), array('id' => "{$prefix}skype_username", 'type' => 'text', 'name' => __('Skype Username', 'VRC'), 'desc' => __('Example Value: myskypeID', 'VRC')), array('id' => "{$prefix}insta_url", 'type' => 'url', 'name' => __('Instagram URL', 'VRC')), array('id' => "{$prefix}ytube_url", 'type' => 'url', 'name' => __('Youtube URL', 'VRC'))));
     // Metboxes array ended.
     $meta_boxes[] = array('id' => 'vr_agent_meta_box_rental_id', 'title' => __('Rental Properties Owner', 'VRC'), 'post_types' => array('vr_agent'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('id' => "{$prefix}rental_owner", 'type' => 'custom_html', 'callback' => function () {
         global $post;
         // Get the rentals where `vr_rental_the_agent` is this agent.
         // That is get the rentals where this agent is the owner.
         $args = array('post_type' => 'vr_rental', 'orderby' => 'meta_value_num', 'meta_key' => 'vr_rental_the_agent', 'meta_value' => $post->ID);
         $the_rentals = new WP_Query($args);
         echo '<div class="rwmb-field">';
         if ($the_rentals->have_posts()) {
             echo '<ol>';
             while ($the_rentals->have_posts()) {
                 $the_rentals->the_post();
                 // Frontend link.
                 // $li_format = '<li><a href="%s"> %s </a></li>';
                 // echo sprintf( $li_format, get_the_permalink() , get_the_title() );
                 // Backend link.
                 $li_format = '<li><a href="/wp-admin/post.php?post=%s&action=edit"> %s </a></li>';
                 echo sprintf($li_format, get_the_id(), get_the_title());
             }
             echo '</ol>';
         } else {
             echo "No rental property owned by this agent.";
         }
         echo '</div>';
     })));
     // Metboxes array ended.
     return $meta_boxes;
 }
开发者ID:WPTie,项目名称:VRCore,代码行数:39,代码来源:class-agent-meta-boxes.php

示例7: ac_remove_wpautop

/**
 *
 */
function ac_remove_wpautop()
{
    $ac_remove_autop = get_field('ac_remove_auto_p', get_the_id());
    if ($ac_remove_autop != false) {
        remove_filter('the_content', 'wpautop');
    }
}
开发者ID:ambercouch,项目名称:wp-ac-remove-autop,代码行数:10,代码来源:actions.php

示例8: go

function go()
{
    //##############################################################
    global $conn_start_up;
    //##############################################################
    //##############################################################
    //pass the user identification key
    $current_user_index = get_the_id($conn_start_up, '');
    if (!$current_user_index) {
        //log one error
    }
    //##############################################################
    //##############################################################
    //extract the user current ranks
    $extract_the_user_odds = mysqli_query($conn_start_up, "select (involved+earned) from '{$table_allusers}' where index_='{$current__user_index}'");
    //change the formula here
    $fetched_odds_for_logged_in = mysqli_fetch_array($conn_start_up, $extract_the_user_odds);
    $odds_for_current_user = $fetched_odds_for_logged_in['involved+earned'];
    //##############################################################
    //##############################################################
    //pass the user rank and id to be  matched
    match_the_user($current_user_index, $odds_for_current_user);
    //no return
    //##############################################################
}
开发者ID:rubulh,项目名称:ants,代码行数:25,代码来源:go.php

示例9: migrate

 /**
  * Migrate meta values to taxonomy terms. Delete meta after import
  *
  * ## OPTIONS
  *
  * <meta-key>
  * : Meta key to convert
  *
  * <taxonomy-slug>
  * : Taxonomy to move values into
  *
  * [--<field>=<value>]
  * : One or more args to pass to WP_Query.
  *
  * ## EXAMPLES
  *
  *     wp mtt migrate meta_key taxonomy_slug
  *     wp mtt migrate meta_key taxonomy_slug --posts_per_page=200 --paged=2
  *
  */
 function migrate($args, $assoc_args)
 {
     list($meta_key, $taxonomy) = $args;
     if (!($taxonomy_object = get_taxonomy($taxonomy))) {
         WP_CLI::error(sprintf("The taxonomy '%s' doesn't exist", $taxonomy));
     }
     $defaults = array('post_type' => $taxonomy_object->object_type, 'posts_per_page' => -1, 'post_status' => 'any');
     $query_args = array_merge($defaults, $assoc_args);
     $query = new WP_Query($query_args);
     // summary
     WP_CLI::log(sprintf("---\nPer page: %d \nPage: %d \nTotal pages: %d\n---", $query_args['posts_per_page'], isset($query_args['paged']) ? $query_args['paged'] : 1, $query->max_num_pages));
     while ($query->have_posts()) {
         $query->the_post();
         $id = get_the_id();
         // get meta
         $metas = get_post_meta($id, $meta_key);
         // create term
         if (!$metas) {
             WP_CLI::log(WP_CLI::colorize("%c[{$id}]%n No meta, skipped"));
         } else {
             if (!is_wp_error(wp_set_object_terms($id, $metas, $taxonomy, true))) {
                 WP_CLI::log(WP_CLI::colorize("%g[{$id}]%n Migrated: " . implode(', ', $metas)));
                 // clean meta
                 delete_post_meta($id, $meta_key);
             } else {
                 WP_CLI::log(WP_CLI::colorize("%r[{$id}]%n Error: Could not set terms for post"));
             }
         }
     }
 }
开发者ID:trepmal,项目名称:wp-cli-meta-to-term,代码行数:50,代码来源:meta-to-term-cli.php

示例10: getPriceWithLabel

 function getPriceWithLabel()
 {
     global $TLPfoodmenu;
     $settings = get_option($TLPfoodmenu->options['settings']);
     $currency = @$settings['general']['currency'] ? esc_attr(@$settings['general']['currency']) : "USD";
     $currencyP = @$settings['general']['currency_position'] ? esc_attr(@$settings['general']['currency_position']) : "right";
     @($price = get_post_meta(get_the_id(), 'price', true));
     $cList = $TLPfoodmenu->currency_list();
     $symbol = $cList[$currency]['symbol'];
     switch ($currencyP) {
         case 'left':
             $price = $symbol . $price;
             break;
         case 'right':
             $price = $price . $symbol;
             break;
         case 'left_space':
             $price = $symbol . " " . $price;
             break;
         case 'right_space':
             $price = $price . " " . $symbol;
             break;
         default:
             break;
     }
     return $price;
 }
开发者ID:dorkyhuman,项目名称:things,代码行数:27,代码来源:FmFunction.php

示例11: wp_nav_menu_objects_filter

 public function wp_nav_menu_objects_filter($items, $args)
 {
     if (is_array($items) && !empty($args->theme_location)) {
         $home = false;
         if (is_page()) {
             if ($this->content->pageTemplate() === "page-home.php") {
                 $home = get_page_link(get_the_id());
             }
         }
         foreach ($items as $id => $item) {
             if (!empty($item->post_parent)) {
                 if ($item->object === "page") {
                     $page = get_page($item->object_id);
                     if (!empty($page->post_name)) {
                         $parent = get_page_link($item->post_parent);
                         $slug = $page->post_name;
                         $items[$id]->url = "{$parent}#{$slug}";
                     }
                 }
             } else {
                 if ($item->url === $home) {
                     $items[$id]->url .= "#home";
                 }
             }
         }
     }
     return $items;
 }
开发者ID:JeffreyBue,项目名称:jb,代码行数:28,代码来源:PeThemeVisia.php

示例12: add_snippet

 /**
  * Add custom javascript within head section.
  *
  * @since 1.0.0
  */
 public function add_snippet()
 {
     if (\is_admin()) {
         return;
     }
     if (\is_feed()) {
         return;
     }
     if (\is_robots()) {
         return;
     }
     if (\is_trackback()) {
         return;
     }
     $disable_recording = boolval(\get_post_meta(\get_the_id(), 'smartlook_disable_rec', true));
     // Disable recording for this content type
     if ($disable_recording) {
         return;
     }
     $snippet = trim(\get_option('smartlook_snippet'));
     if (empty($snippet)) {
         return;
     }
     echo $snippet;
 }
开发者ID:s3rgiosan,项目名称:wpsmartlook,代码行数:30,代码来源:Frontend.php

示例13: instapaper_button

/**
 * Add the link to the item actions
 *
 * @param array $actions Previous actions
 * @return array Array with Tweet It added.
 */
function instapaper_button($actions)
{
    require_once LILINA_PATH . '/admin/includes/common.php';
    $tweet_url = sprintf(get_option('baseurl') . '?method=instapaper&id=%1$s&_nonce=%2$s', get_the_id(), generate_nonce());
    $actions[] = '<a href="' . $tweet_url . '" class="instapaper_button" title="' . _r('Save to Instapaper', 'instapaper') . '">' . _r('Read Later', 'instapaper') . '</a>';
    return $actions;
}
开发者ID:rmccue,项目名称:Lilina,代码行数:13,代码来源:instapaper.php

示例14: gs_logo_shortcode

function gs_logo_shortcode($atts)
{
    extract(shortcode_atts(array('posts' => -1, 'order' => 'DESC', 'orderby' => 'date', 'title' => 'no'), $atts));
    $loop = new WP_Query(array('post_type' => 'gs-logo-slider', 'order' => 'DESC', 'orderby' => 'date', 'title' => $title, 'posts_per_page' => 20));
    $output = '<div class="gs_logo_container">';
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            $meta = get_post_meta(get_the_id());
            $gs_logo_id = get_post_thumbnail_id();
            $gs_logo_url = wp_get_attachment_image_src($gs_logo_id, array(200, 200), true);
            $gs_logo = $gs_logo_url[0];
            $gs_logo_alt = get_post_meta($gs_logo_id, '_wp_attachment_image_alt', true);
            $output .= '<div class="gs_logo_single">';
            if ($meta['client_url'][0]) {
                $output .= '<a href="' . $meta['client_url'][0] . '" target="_blank">';
            }
            if ($gs_logo) {
                $output .= '<img src="' . $gs_logo . '" alt="' . $gs_logo_alt . '" >';
            }
            if ($meta['client_url'][0]) {
                $output .= '</a>';
            }
            if ($title == "yes") {
                $output .= '<h3 class="gs_logo_title">' . get_the_title() . '</h3>';
            }
            $output .= '</div>';
        }
    } else {
        $output .= "No Logo Added!";
    }
    $output .= '</div>';
    return $output;
}
开发者ID:bunnywong,项目名称:freshlinker,代码行数:34,代码来源:gs-logo-shortcode.php

示例15: impronta_metadata

 /**
  * Prints HTML with meta information for the current post-date/time and author.
  */
 function impronta_metadata()
 {
     // Hide category and tag text for pages.
     if ('post' === get_post_type()) {
         echo '<p class="metadata">';
         $byline = sprintf(esc_html_x('By %s', 'post author', 'impronta'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span> ');
         echo $byline;
         /* translators: used between list items, there is a space after the comma */
         $categories_list = get_the_category_list(esc_html__(', ', 'impronta'));
         if ($categories_list && impronta_categorized_blog()) {
             printf('<span class="cat-links">' . esc_html_x('on %1$s ', 'on categories', 'impronta') . '</span>', $categories_list);
             // WPCS: XSS OK.
         }
         /* translators: used between list items, there is a space after the comma */
         $tags_list = get_the_tag_list('', esc_html__(', ', 'impronta'));
         if ($tags_list) {
             printf(esc_html__('tagged %1$s', 'impronta'), $tags_list);
             // WPCS: XSS OK.
         }
         if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
             if (get_comments_number(get_the_id()) == 0) {
                 echo esc_html__('- ', 'impronta');
             } else {
                 echo esc_html__('with ', 'impronta');
             }
             comments_popup_link(esc_html__('Leave a comment', 'impronta'), esc_html__('1 Comment', 'impronta'), esc_html__('% Comments', 'impronta'));
         }
         if (is_sticky()) {
             echo ' - ' . '<i class="feature-star fa fa-star" data-toggle="tooltip" data-placement="right" title="' . esc_attr__('Featured Post', 'impronta') . '"></i>';
         }
         echo '</p>';
     }
 }
开发者ID:nicoandrade,项目名称:Impronta,代码行数:36,代码来源:template-tags.php


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