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


PHP WP_query::query方法代码示例

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


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

示例1: SPD2012_insertPage

/**
 * Create a shortcode to insert content of a page of specified ID
 *
 * @param    array        attributes of shortcode
 * @return     string        $output        Content of page specified, if no page id specified output = null
 */
function SPD2012_insertPage($atts, $content = null)
{
    // Default output if no pageid given
    $output = NULL;
    // extract atts and assign to array
    extract(shortcode_atts(array("page" => ''), $atts));
    // if a page id is specified, then run query
    if (!empty($page)) {
        $pageContent = new WP_query();
        $pageContent->query(array('pagename' => $page));
        while ($pageContent->have_posts()) {
            $pageContent->the_post();
            // assign the content to $output
            $output = get_the_content();
        }
    }
    return $output;
}
开发者ID:AK-Digitale-Gesellschaft,项目名称:Wordpress-Theme,代码行数:24,代码来源:shortcodePageInsert.php

示例2: url

				    </section>
				<?php 
}
?>

				<section class="latest-case-study">
					<?php 
// Need to Make This One Dynamic. For now Just Enter in the Case Study Page ID You want to show
?>
						<span style="background-image: url('/wp-content/uploads/niswonger-banner-small.jpg');"></span>
						<div class="slide-left">
							<header>
								<h2>Latest Case Study</h2>
								<?php 
$query_post = new WP_query();
$query_post->query('post_type=page&page_id=868');
while ($query_post->have_posts()) {
    $query_post->the_post();
    ?>
										<h3><a href="<?php 
    echo the_permalink();
    ?>
"><?php 
    echo get_the_title();
    ?>
</a></h3>
										<?php 
    $excerpt = get_field('case_study_excerpt');
    if (!empty($excerpt)) {
        ?>
											<?php 
开发者ID:andandandandrew,项目名称:New-LIFT,代码行数:31,代码来源:template_home.php

示例3: url

<?php

/*
Template Name: Case Study Page
*/
get_header();
?>

	<main role="main" role="main">
		<section class="the-goods">
		<?php 
$query_post = new WP_query();
$query_post->query('post_type=page&post_parent=18&orderby=menu_order&order=ASC&paged');
while ($query_post->have_posts()) {
    $query_post->the_post();
    ?>
			<article id="<?php 
    echo $post->post_name;
    ?>
">
				
				<section class="case-study-banner" style="background: url('<?php 
    $image = get_field('case_study_home-page-image');
    if (!empty($image)) {
        echo $image['url'];
    }
    ?>
');">
					<header>
						<div>
							<?php 
开发者ID:andandandandrew,项目名称:New-LIFT,代码行数:31,代码来源:template_case-study-page.php

示例4: foreach

    function mantra_frontpage_generator()
    {
        $mantra_options = mantra_get_theme_options();
        foreach ($mantra_options as $key => $value) {
            ${"{$key}"} = $value;
        }
        ?>

<script type="text/javascript">

	// Flash animation for columns


    jQuery(document).ready(function() {
	// Slider creation
        jQuery('#slider').nivoSlider({

			effect: '<?php 
        echo $mantra_fpslideranim;
        ?>
',
       		animSpeed: <?php 
        echo $mantra_fpslidertime;
        ?>
,
			<?php 
        if ($mantra_fpsliderarrows == "Hidden") {
            ?>
 directionNav: false, <?php 
        }
        if ($mantra_fpsliderarrows == "Always Visible") {
            ?>
  directionNav: true, <?php 
        }
        ?>
			pauseTime: <?php 
        echo $mantra_fpsliderpause;
        ?>

						});

    jQuery('#front-columns > div img').hover( function() {
	      jQuery(this)
			 .stop()
             .animate({opacity: 0.5}, 100)
             .fadeOut(100)
			 .fadeIn(100)
             .animate({opacity: 0.999}, 100) ;
	}, function() {jQuery(this).stop();} )

		});
	</script>

<div id="frontpage">
<?php 
        // First FrontPage Title
        if ($mantra_fronttext1) {
            ?>
<div id="front-text1"> <h1><?php 
            echo esc_attr($mantra_fronttext1);
            ?>
 </h1></div><?php 
        }
        // When a post query has been selected from the Slider type in the admin area
        if ($mantra_slideType != 'Custom Slides') {
            global $post;
            // Initiating query
            $custom_query = new WP_query();
            // Switch for Query type
            switch ($mantra_slideType) {
                case 'Latest Posts':
                    $custom_query->query('showposts=' . $mantra_slideNumber . '&ignore_sticky_posts=1');
                    break;
                case 'Random Posts':
                    $custom_query->query('showposts=' . $mantra_slideNumber . '&orderby=rand&ignore_sticky_posts=1');
                    break;
                case 'Latest Posts from Category':
                    $custom_query->query('showposts=' . $mantra_slideNumber . '&category_name=' . $mantra_slideCateg . '&ignore_sticky_posts=1');
                    break;
                case 'Random Posts from Category':
                    $custom_query->query('showposts=' . $mantra_slideNumber . '&category_name=' . $mantra_slideCateg . '&orderby=rand&ignore_sticky_posts=1');
                    break;
                case 'Sticky Posts':
                    $custom_query->query(array('post__in' => get_option('sticky_posts'), 'showposts' => $mantra_slideNumber, 'ignore_sticky_posts' => 1));
                    break;
                case 'Specific Posts':
                    // Transofm string separated by commas into array
                    $pieces_array = explode(",", $mantra_slideSpecific);
                    $custom_query->query(array('post_type' => 'any', 'showposts' => -1, 'post__in' => $pieces_array, 'ignore_sticky_posts' => 1, 'orderby' => 'post__in'));
                    break;
            }
            // Variables i and j for matching slider number with caption number
            $i = 0;
            $j = 0;
            ?>
 <div class="slider-wrapper theme-default">
            <div class="ribbon"></div>
  <div id="slider" class="nivoSlider <?php 
            if ($mantra_fpsliderarrows == "Visible on Hover") {
                ?>
//.........这里部分代码省略.........
开发者ID:zhebiewang,项目名称:WP,代码行数:101,代码来源:theme-frontpage.php

示例5: widget

    function widget($args, $instance)
    {
        extract($args);
        $query_args = array('posts_per_page' => $instance['number_of_posts'], 'post__not_in' => array($post->ID));
        $recent_posts = new WP_query();
        $recent_posts->query($query_args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget . $before_title . $title . $after_title;
        echo '<ol id="raw_recent_posts">';
        if ($recent_posts->have_posts()) {
            while ($recent_posts->have_posts()) {
                $recent_posts->the_post();
                ?>
					
					<li>
						<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_post_thumbnail('55x55');
                ?>
</a>
						<h5><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h5>
						<em><?php 
                the_time(get_option('date_format'));
                ?>
</em>
					</li>

				<?php 
            }
        } else {
            echo '<li><h6>' . _e("No recent posts.", "raw_theme") . '</h6></li>';
        }
        echo '</ol>';
        echo $after_widget;
    }
开发者ID:nishant368,项目名称:newlifeoffice-new,代码行数:43,代码来源:raw_widgets.php

示例6: while

<?php

get_header();
?>
<div id="post">
	<ul>
	<?php 
$q = new WP_query();
$q->query("post_type=question&post_status=publish&posts_per_page=20");
if (have_posts()) {
    while ($q->have_posts()) {
        $q->the_post();
        $s = new questionSubmit();
        ?>

	<li id="n2-<?php 
        the_ID();
        ?>
" class="user_id_<?php 
        the_author_ID();
        ?>
">
		<a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title();
        ?>
"><?php 
        the_title();
        ?>
开发者ID:jaredwilli,项目名称:wp3theme,代码行数:31,代码来源:page-questions.php

示例7: array

        echo do_shortcode($nirvana_fronttext3);
        ?>
</div><?php 
    }
    ?>
</div><?php 
}
//COLUMNS
// Initiating query
$custom_query2 = new WP_query();
$columns = array();
if ($nirvana_columnNumber > 0) {
    // Switch for Query type
    switch ($nirvana_columnType) {
        case 'Latest Posts':
            $custom_query2->query('showposts=' . $nirvana_columnNumber . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts':
            $custom_query2->query('showposts=' . $nirvana_columnNumber . '&orderby=rand&ignore_sticky_posts=1');
            break;
        case 'Latest Posts from Category':
            $custom_query2->query('showposts=' . $nirvana_columnNumber . '&category_name=' . $nirvana_columnCateg . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts from Category':
            $custom_query2->query('showposts=' . $nirvana_columnNumber . '&category_name=' . $nirvana_columnCateg . '&orderby=rand&ignore_sticky_posts=1');
            break;
        case 'Sticky Posts':
            $custom_query2->query(array('post__in' => get_option('sticky_posts'), 'showposts' => $nirvana_columnNumber, 'ignore_sticky_posts' => 1));
            break;
        case 'Specific Posts':
            // Transofm string separated by commas into array
开发者ID:RishabhTayal,项目名称:GandF,代码行数:31,代码来源:frontpage.php

示例8: while

<?php

if (is_page('sites')) {
    ?>

		<?php 
    $q = new WP_query();
    $q->query('post_type=site');
    if ($q->have_posts()) {
        while ($q->have_posts()) {
            $q->the_post();
            $s = new TypeSites();
            $a = $s->mshot(250);
            ?>

			<div id="site-<?php 
            the_ID();
            ?>
" class="sites clearfix user_id_<?php 
            the_author_ID();
            ?>
">
				<div class="site-thumbnail">
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
">
						<?php 
开发者ID:jaredwilli,项目名称:3.0basics,代码行数:31,代码来源:loop-sites.php

示例9: array

    ?>
<div id="front-text1"> <h1><?php 
    echo esc_attr($parabola_fronttext1);
    ?>
 </h1></div><?php 
}
// When a post query has been selected from the Slider type in the admin area
global $post;
// Initiating query
$custom_query = new WP_query();
$slides = array();
if ($parabola_slideNumber > 0) {
    // Switch for Query type
    switch ($parabola_slideType) {
        case 'Latest Posts':
            $custom_query->query('showposts=' . $parabola_slideNumber . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts':
            $custom_query->query('showposts=' . $parabola_slideNumber . '&orderby=rand&ignore_sticky_posts=1');
            break;
        case 'Latest Posts from Category':
            $custom_query->query('showposts=' . $parabola_slideNumber . '&category_name=' . $parabola_slideCateg . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts from Category':
            $custom_query->query('showposts=' . $parabola_slideNumber . '&category_name=' . $parabola_slideCateg . '&orderby=rand&ignore_sticky_posts=1');
            break;
        case 'Sticky Posts':
            $custom_query->query(array('post__in' => get_option('sticky_posts'), 'showposts' => $parabola_slideNumber, 'ignore_sticky_posts' => 1));
            break;
        case 'Specific Posts':
            // Transofm string separated by commas into array
开发者ID:jlederman,项目名称:subproj,代码行数:31,代码来源:frontpage.php

示例10: while

<?php

get_header();
?>
	<div class="navigation"><p><?php 
posts_nav_link();
?>
</p></div>
	<div class="gallery-thumbs">
		<ul>
		<?php 
$q = new WP_query();
$q->query("post_type=site&post_status=publish&posts_per_page=9");
if (have_posts()) {
    /*$previous_user_id = 0; $previous_user_id = */
    while ($q->have_posts()) {
        $q->the_post();
        $s = new siteSubmit();
        // var_dump($s->mshot('200'));
        // die;
        ?>

			<li id="n2-<?php 
        the_ID();
        ?>
" class="user_id_<?php 
        the_author_ID();
        ?>
">
				<a href="<?php 
        the_permalink();
开发者ID:jaredwilli,项目名称:wp3theme,代码行数:31,代码来源:page-gallery.php

示例11: while

<?php

get_header();
?>
<div id="post">
	<ul>
	<?php 
$q = new WP_query();
$q->query("post_type=snip&post_status=publish&posts_per_page=20");
if (have_posts()) {
    while ($q->have_posts()) {
        $q->the_post();
        $s = new snipSubmit();
        ?>

	<li id="n2-<?php 
        the_ID();
        ?>
" class="user_id_<?php 
        the_author_ID();
        ?>
">
		<a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title();
        ?>
"><?php 
        the_title();
        ?>
开发者ID:jaredwilli,项目名称:wp3theme,代码行数:31,代码来源:page-snippets.php

示例12: while

<ul class="row list-my-products">
<?php 
$top_cats = new WP_query();
$top_cats->query('showposts=6&cat=6');
?>

				        <?php 
if (have_posts()) {
    ?>

				          <?php 
    while ($top_cats->have_posts()) {
        $top_cats->the_post();
        ?>
		<li class="col-sm-4 col-xs-6 item">
			<div class="inner">
				<!-- post thumbnail -->
				<?php 
        if (has_post_thumbnail()) {
            // Check if thumbnail exists
            ?>
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
">
						<!-- post thumbnail -->
				<?php 
            if (has_post_thumbnail()) {
开发者ID:JN88,项目名称:sob4,代码行数:31,代码来源:widget-my-product.php

示例13: extract

    static function handle_shortcode($atts)
    {
        self::$add_script = true;
        extract(shortcode_atts(array('class' => false, 'page' => get_the_ID()), $atts, 'content'));
        ob_start();
        // Default output if no pageid given
        $output = NULL;
        // extract atts and assign to array
        // if a page id is specified, then run query
        if (!empty($page)) {
            $pageContent = new WP_query();
            $pageContent->query(array('page_id' => $page, 'post_type' => array('page', 'ai1ec_event')));
            while ($pageContent->have_posts()) {
                $pageContent->the_post();
                // assign the content to $output
                the_content();
            }
            wp_reset_query();
        }
        ?>
			
			
			
			
			
		<?php 
        $content = ob_get_clean();
        return $content;
    }
开发者ID:ThatGuySam,项目名称:warp-drive,代码行数:29,代码来源:organisms.php

示例14: while

<div class="section-heading mgB20">
	<h3 class="section-title  text-left">Tin tức Của chúng tôi</h3>
</div>
<ul class="list-news">
<?php 
$top_cats = new WP_query();
$top_cats->query('showposts=3&cat=7');
?>

				        <?php 
if (have_posts()) {
    ?>

				          <?php 
    while ($top_cats->have_posts()) {
        $top_cats->the_post();
        ?>
		<li>
			<div class="media">
				<div class="pull-left">
					<a href="<?php 
        the_permalink();
        ?>
">
						<?php 
        if (has_post_thumbnail()) {
            // Check if thumbnail exists
            echo get_the_post_thumbnail($post_id, 'thumbnail', array('class' => 'img-responsive w80'));
        }
        ?>
					</a>
开发者ID:JN88,项目名称:sob4,代码行数:31,代码来源:widget-my-news.php

示例15: array

if ($iced_mocha_fronttext3) {
    ?>
<div id="front-text3"> <blockquote><?php 
    echo do_shortcode($iced_mocha_fronttext3);
    ?>
 </blockquote></div><?php 
}
//COLUMNS
// Initiating query
$custom_query2 = new WP_query();
$columns = array();
if ($iced_mocha_columnNumber > 0 || $iced_mocha_columnNumberEvents > 0) {
    // Switch for Query type
    switch ($iced_mocha_columnType) {
        case 'Latest Events':
            $custom_query2->query('post_type=espresso_events&showposts=' . $iced_mocha_columnNumberEvents);
            break;
        case 'Random Events':
            $custom_query2->query('post_type=espresso_events&showposts=' . $iced_mocha_columnNumberEvents . '&orderby=rand');
            break;
        case 'Latest Posts':
            $custom_query2->query('showposts=' . $iced_mocha_columnNumber . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts':
            $custom_query2->query('showposts=' . $iced_mocha_columnNumber . '&orderby=rand&ignore_sticky_posts=1');
            break;
        case 'Latest Posts from Category':
            $custom_query2->query('showposts=' . $iced_mocha_columnNumber . '&category_name=' . $iced_mocha_columnCateg . '&ignore_sticky_posts=1');
            break;
        case 'Random Posts from Category':
            $custom_query2->query('showposts=' . $iced_mocha_columnNumber . '&category_name=' . $iced_mocha_columnCateg . '&orderby=rand&ignore_sticky_posts=1');
开发者ID:JBNavadiya,项目名称:iced-mocha,代码行数:31,代码来源:frontpage.php


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