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


PHP WP_Query::get_queried_object_id方法代码示例

本文整理汇总了PHP中WP_Query::get_queried_object_id方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Query::get_queried_object_id方法的具体用法?PHP WP_Query::get_queried_object_id怎么用?PHP WP_Query::get_queried_object_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Query的用法示例。


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

示例1: wp_infinite_scroll_project

function wp_infinite_scroll_project()
{
    $paged = $_POST['page_no'];
    $filterName = $_POST['filter_name'];
    $current_url = $_POST['current_url'];
    $page_url = basename($current_url);
    $args = array('post_type' => 'project', 'project-category' => $page_url, 'posts_per_page' => '9', 'paged' => $paged, 'post_status' => 'publish');
    $wp_query = new WP_Query($args);
    $page_id = $wp_query->get_queried_object_id();
    //var_dump($page_id);
    if ($wp_query->have_posts()) {
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            ?>


					<!-- Thumbnail -->

					<?php 
            $project_cat = '';
            $terms = get_the_terms(get_the_ID(), 'project-industry');
            if ($terms && !is_wp_error($terms)) {
                $project_cats = array();
                foreach ($terms as $term) {
                    $project_cats[] = $term->slug;
                }
                $project_cat = join(' ', $project_cats);
                ?>


					<?php 
            }
            if (!empty($terms)) {
                if (is_array($project_cats) && in_array($filterName, $project_cats) || $filterName == 'all') {
                    ?>


							<li class="thumbnail mix <?php 
                    echo $project_cat;
                    ?>
 mix_all" style="opacity: 1; display: block;">

								<a href="<?php 
                    the_permalink();
                    ?>
" >

									<?php 
                    the_post_thumbnail('project-thumb');
                    ?>


									<div class="projectinfo">

										<div class="meta">

											<h4><?php 
                    the_title();
                    ?>
</h4>

										</div>

									</div>

								</a>

							</li>

						<?php 
                } else {
                    ?>


							<li class="thumbnail mix <?php 
                    echo $project_cat;
                    ?>
 mix_all">

								<a href="<?php 
                    the_permalink();
                    ?>
" >

									<?php 
                    the_post_thumbnail('project-thumb');
                    ?>


									<div class="projectinfo">

										<div class="meta">

											<h4><?php 
                    the_title();
                    ?>
</h4>

										</div>

//.........这里部分代码省略.........
开发者ID:viralss,项目名称:sunglow-solution,代码行数:101,代码来源:load-projects.php

示例2: explode

<?php

get_header();
?>

<?php 
$filter = explode(',', $_GET['kur']);
global $wp_query;
$args = array('main_ingredient' => 'fleisch', 'tax_query' => array(array('taxonomy' => 'main_ingredient', 'field' => 'name', 'terms' => $filter, 'operator' => 'NOT IN')));
$wp_query = new WP_Query($args);
$cur_cat_id = $wp_query->get_queried_object_id();
$cur_cat = get_term($cur_cat_id);
$cat_img = get_field('main_ingredient_image', 'main_ingredient_' . $cur_cat_id);
if (!$cat_img) {
    $cat_img = get_site_url() . "/wp-content/uploads/default_cat_img.jpg";
}
$terms = get_terms(array('taxonomy' => 'main_ingredient', 'hide_empty' => true, 'parent' => $cur_cat_id));
// Get size of $terms array
$termsSize = count($terms);
?>


<main role="main">
    <!-- section -->
    <section>

        <div class="wpb_posts_slider qfRecipeCatHeader">
            <div class="qfRecipeCatImg" style="background-image: url('<?php 
echo $cat_img;
?>
');"></div>
开发者ID:victorqf,项目名称:ehoff,代码行数:31,代码来源:timthumb.php

示例3: extract_tax_archive_data

 /**
  * @param WP_Query $wp_query
  *
  * @return array()
  */
 private function extract_tax_archive_data($wp_query)
 {
     $taxonomy = false;
     $term_id = false;
     if ($wp_query->is_category()) {
         $taxonomy = 'category';
         $term_id = $wp_query->get('cat');
     } elseif ($wp_query->is_tag()) {
         $taxonomy = 'post_tag';
         $term_id = $wp_query->get('tag_id');
     } elseif ($wp_query->is_tax()) {
         $taxonomy = $wp_query->get('taxonomy');
         $term_id = $wp_query->get_queried_object_id();
     }
     return array($taxonomy, $term_id);
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:21,代码来源:wpml-languages.class.php

示例4: alter_request

 /**
  * Alternates request
  *
  * @param array $request
  * @return array
  */
 public function alter_request($request)
 {
     if (is_admin()) {
         return $request;
     }
     $mapping = array();
     foreach ($this->get_post_types() as $post_type) {
         $page_id = (int) g1_get_theme_option('post_type_' . $post_type, 'page_for_posts');
         if ($page_id) {
             $mapping[$post_type] = $page_id;
         }
     }
     foreach ($mapping as $post_type => $page_id) {
         // WPML fallback
         if (function_exists('icl_object_id')) {
             $page_id = absint(icl_object_id($page_id, 'page', true));
         }
         if ($page_id) {
             // The query isn't run if we don't pass any query vars
             $query = new WP_Query();
             $query->parse_query($request);
             // Change request from page to post type archive
             if ($query->is_page()) {
                 if (absint($query->get('page_id')) === $page_id || strlen($query->get('pagename')) && absint($query->get_queried_object_id()) === $page_id) {
                     unset($request['page']);
                     unset($request['page_id']);
                     unset($request['pagename']);
                     $request['post_type'] = $post_type;
                 }
             }
         }
     }
     return $request;
 }
开发者ID:aragonc,项目名称:3clicks,代码行数:40,代码来源:features.php


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