本文整理汇总了PHP中WP_query类的典型用法代码示例。如果您正苦于以下问题:PHP WP_query类的具体用法?PHP WP_query怎么用?PHP WP_query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: subpage_peek
function subpage_peek($atts, $content = null)
{
global $post;
// Extract shortcode arguements
extract(shortcode_atts(array('order' => 'asc', 'orderby' => 'menu_order', 'numpages' => '-1', 'hidethumb' => 'false', 'removelinks' => 'false', 'showfullcontent' => 'false'), $atts));
//query subpages
$args = array('post_parent' => $post->ID, 'post_type' => 'page', 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $numpages);
$subpages = new WP_query($args);
$i = 1;
// create output
if ($subpages->have_posts()) {
$output = '<div id="subpage-list">';
while ($subpages->have_posts()) {
$subpages->the_post();
$output .= '<hr /><div class="entry" id="subpage-link-' . $i . '">';
if ($hidethumb == 'false' && has_post_thumbnail()) {
// check if the post has a Post Thumbnail assigned to it.
$output .= '<a href="' . get_permalink() . '" class="alignleft">' . get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => 'wp-post-image')) . '</a>';
}
$output .= '<h3>';
$output .= $removelinks == 'true' ? get_the_title() : '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
$output .= '</h3><p>';
$output .= $showfullcontent == 'true' ? get_the_content() : get_the_excerpt();
if ($removelinks == 'false') {
$output .= '<br /><a href="' . get_permalink() . '"><em>Read more »</em></a>';
}
$output .= '</p>
</div>';
$i++;
}
$output .= '<div style="clear:both;"></div>';
$output .= '</div>';
} else {
$output = '<p>No subpages found.</p>';
}
// reset the query
wp_reset_postdata();
// return something
return $output;
}
开发者ID:sezj,项目名称:ufl-template-responsive,代码行数:40,代码来源:shortcode-subpage-peek.php
示例2: image_cpt_shortcode
function image_cpt_shortcode($attr)
{
if ($attr['page'] <= 10) {
$per_page['page'] = $attr['page'];
} else {
$per_page['page'] = 10;
}
$output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
$args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
$loop = new WP_query($args);
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$output .= '<div class="winner-div"><h3>';
$output .= get_the_title();
$output .= '</h3>';
if (has_post_thumbnail()) {
// check if the post has a post thumbnail assigned to it.
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
$url = $thumb['0'];
$output .= '<img src="' . $url . '"/>';
}
$output .= '</div>';
}
} else {
// if no content, include the "no posts found" template.
get_template_part('content', 'none');
}
return $output;
}
开发者ID:Shane-McCarthy,项目名称:wordpress-custom-theme,代码行数:30,代码来源:functions.php
示例3: widget
function widget($args, $instance)
{
extract($args);
$category = isset($instance['category']) ? $instance['category'] : '';
$postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
$offset = empty($instance['offset']) ? '' : $instance['offset'];
$sticky = isset($instance['sticky']) ? $instance['sticky'] : 0;
echo $before_widget;
?>
<section id="slider-<?php
echo rand(1, 9999);
?>
" class="flexslider">
<ul class="slides"><?php
$args = array('posts_per_page' => $postcount, 'cat' => $category, 'offset' => $offset, 'ignore_sticky_posts' => $sticky);
$slider = new WP_query($args);
while ($slider->have_posts()) {
$slider->the_post();
?>
<li>
<article class="slide-wrap">
<div class="mh-slider-overlay"></div>
<a href="<?php
the_permalink();
?>
" title="<?php
the_title_attribute();
?>
"><?php
if (has_post_thumbnail()) {
the_post_thumbnail('content');
} else {
echo '<img src="' . get_template_directory_uri() . '/images/noimage_content.png' . '" alt="No Picture" />';
}
?>
</a>
<header class="slide-caption">
<a href="<?php
the_permalink();
?>
" title="<?php
the_title_attribute();
?>
"><h2 class="slide-title"><?php
the_title();
?>
</h2></a>
</header>
</article>
</li><?php
}
wp_reset_postdata();
?>
</ul>
</section><?php
echo $after_widget;
}
开发者ID:stealth5,项目名称:luftwaffle,代码行数:57,代码来源:mh-slider.php
示例4: wp_stripe_options_display_projects
/**
* Projects - Display projects within options page
*/
function wp_stripe_options_display_projects()
{
// Query Custom Post Types
$args = array('post_type' => 'wp-stripe-projects', 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => 'wp-stripe-completion', 'order' => 'ASC', 'posts_per_page' => 50);
// - query -
$my_query = null;
$my_query = new WP_query($args);
while ($my_query->have_posts()) {
$my_query->the_post();
$time_format = get_option('time_format');
// - variables -
$custom = get_post_custom(get_the_ID());
$id = $my_query->post->ID;
$public = $custom["wp-stripe-public"][0];
$live = $custom["wp-stripe-live"][0];
$name = $custom["wp-stripe-name"][0];
$email = $custom["wp-stripe-email"][0];
$content = get_the_content();
$date = $custom["wp-stripe-date"][0];
$cleandate = date('d M', $date);
$cleantime = date('H:i', $date);
$amount = $custom["wp-stripe-amount"][0];
$fee = $custom["wp-stripe-fee"][0] / 100;
$net = round($amount - $fee, 2);
echo '<tr>';
// Dot
if ($live == 'LIVE') {
$dotlive = '<div class="dot-stripe-live"></div>';
} else {
$dotlive = '<div class="dot-stripe-test"></div>';
}
if ($public == 'YES') {
$dotpublic = '<div class="dot-stripe-public"></div>';
} else {
$dotpublic = '<div class="dot-stripe-test"></div>';
}
// Person
$img = get_avatar($email, 32);
$person = $img . ' <span class="stripe-name">' . $name . '</span>';
// Received
$received = '<span class="stripe-netamount"> + ' . $net . '</span> (-' . $fee . ')';
// Content
echo '<td>' . $dotlive . $dotpublic . '</td>';
echo '<td>' . $person . '</td>';
echo '<td>' . $received . '</td>';
echo '<td>' . $cleandate . ' - ' . $cleantime . '</td>';
echo '<td class="stripe-comment">"' . $content . '"</td>';
echo '</tr>';
}
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:53,代码来源:stripe-options-projects.php
示例5: mon_espace_pub_show
function mon_espace_pub_show()
{
$args = array('post_type' => 'slider', 'ignore_sticky_posts' => true);
$pub = new WP_query($args);
if ($pub->have_posts()) {
echo "<div id='pub'>";
while ($pub->have_posts()) {
$pub->the_post();
echo "<div class='la_pub'>";
the_post_thumbnail('slider');
echo "</div>";
}
echo "</div>";
wp_reset_postdata();
}
}
开发者ID:Katario,项目名称:mon_espace_pub,代码行数:16,代码来源:mon_espace_pub.php
示例6: 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
示例7: suffusion_get_headlines
/**
* Magazine template function to get headlines
*
* @return array
*/
function suffusion_get_headlines()
{
global $post, $wpdb, $suf_mag_headline_limit;
$headlines = array();
$solos = array();
$suf_mag_headline_limit = (int) $suf_mag_headline_limit;
$quota_full = false;
// Previously the script was loading all posts into memory using get_posts and checking the meta field. This causes the code to crash if the # posts is high.
$querystr = "SELECT wposts.*\n\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta\n\t\tWHERE wposts.ID = wpostmeta.post_id\n\t AND wpostmeta.meta_key = 'suf_magazine_headline'\n\t AND wpostmeta.meta_value = 'on'\n\t AND wposts.post_status = 'publish'\n\t AND wposts.post_type = 'post'\n\t ORDER BY wposts.post_date DESC\n\t ";
$head_posts = $wpdb->get_results($querystr, OBJECT);
foreach ($head_posts as $post) {
setup_postdata($post);
$headlines[] = $post;
$solos[] = $post->ID;
if (count($headlines) == $suf_mag_headline_limit) {
$quota_full = true;
break;
}
}
if ($quota_full) {
return $headlines;
}
$headline_categories = suffusion_get_allowed_categories('suf_mag_headline_categories');
if (is_array($headline_categories) && count($headline_categories) > 0) {
$query_cats = array();
foreach ($headline_categories as $headline_category) {
$query_cats[] = $headline_category->cat_ID;
}
$query_posts = implode(",", array_values($query_cats));
$cat_query = new WP_query(array('cat' => $query_posts, 'post__not_in' => $solos));
}
if (isset($cat_query->posts) && is_array($cat_query->posts)) {
while ($cat_query->have_posts()) {
$cat_query->the_post();
$headlines[] = $post;
if (count($headlines) == $suf_mag_headline_limit) {
$quota_full = true;
break;
}
}
}
return $headlines;
}
开发者ID:kevinaxu,项目名称:99boulders,代码行数:48,代码来源:magazine-functions.php
示例8: my_diapordg_show
/**
* Permet d'afficher le carrousel
**/
function my_diapordg_show($limit = 8)
{
//on importe le JS
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js', null, '5.6.4', true);
wp_enqueue_script('caroufredsel', plugins_url() . '/exro/js/jquery.carouFredSel-6.0.4-packed.js', array('jquery'), '5.6.4', true);
add_action('wp_footer', 'my_diapordg_script', 30);
//On écrit le Html
$slides = new WP_query('post_type=slide&posts_per_page=' . $limit);
echo "<div id='my_diapordg'>";
while ($slides->have_posts()) {
$slides->the_post();
global $post;
echo '<a style="display:block; float:left; height:200;" href="' . esc_attr(get_post_meta($post->ID, '_link', true)) . '">';
the_post_thumbnail('slider', array('style' => 'width:200px!important;'));
echo '</a>';
}
echo "</div>";
}
开发者ID:alexrdg,项目名称:rodriguez_plugin,代码行数:22,代码来源:exro.php
示例9: get_header
*
* @package SKT Healing Touch
*/
get_header();
?>
<div class="all-box">
<div class="feature-box-main site-aligner">
<?php
for ($f = 1; $f < 5; $f++) {
?>
<?php
if (get_theme_mod('page-setting' . $f)) {
?>
<?php
$queryvar = new WP_query('page_id=' . get_theme_mod('page-setting' . $f, true));
?>
<?php
while ($queryvar->have_posts()) {
$queryvar->the_post();
?>
<div class="feature-box <?php
if ($f % 4 == 0) {
?>
last<?php
}
?>
">
<?php
the_post_thumbnail();
?>
开发者ID:rictocco,项目名称:cardiosalud,代码行数:31,代码来源:front-page.php
示例10: ot_get_option
/* ]]> */
</script>
<?php
if (ot_get_option('news-category-title')) {
?>
<span class="breaking"> <?php
echo ot_get_option('news-category-title');
?>
</span><?php
}
?>
<ul id="ticker">
<?php
$newscategory = ot_get_option('news-category');
$categorynum = ot_get_option('news-category-num');
$queryObject = new WP_query(array('category__and' => $newscategory, 'posts_per_page' => $categorynum));
if ($queryObject->have_posts()) {
while ($queryObject->have_posts()) {
$queryObject->the_post();
?>
<li><a href="<?php
the_permalink();
?>
"><span><time class="post_date date updated" datetime="<?php
the_time('j M, Y');
?>
"><?php
echo time_ago();
?>
</time></span> <b class="post-title entry-title"><?php
the_title();
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:head_sec.php
示例11: WP_query
<?php
if (!isset($module_query_args)) {
return;
}
$the_query = new WP_query($module_query_args);
if ($the_query->have_posts()) {
?>
<div class="module">
<?php
if (isset($module_query_args['fw_heading']['title'])) {
$module_title = $module_query_args['fw_heading']['title'];
if (isset($module_query_args['fw_heading']['link'])) {
//die(var_dump($module_query_args['fw_heading']['link']));
$module_title = '<a href="' . $module_query_args['fw_heading']['link'] . '">' . $module_title . '<i class="skin-icon skin-icon-plus"></i></a>';
}
echo '<div class="module-heading">' . '<h3 class="module-title">' . $module_title . '</h3>' . '</div>';
}
?>
<?php
while ($the_query->have_posts()) {
$the_query->the_post();
?>
<?php
/**
* Exclude these post in home page listing
*/
if (isset($post_to_exclude) && !in_array($post->ID, $post_to_exclude)) {
$post_to_exclude[] = $post->ID;
}
?>
开发者ID:howblect,项目名称:2015_blect_net,代码行数:31,代码来源:listing-grid-excerpt.php
示例12: WP_query
</h2>
<p><?php
echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis malesuada ex non magna convallis aliquam. Nulla ullamcorper elit a ante ullamcorper, nec malesuada <br> massa commodo. In ut nisi nisl. Nullam porta fringilla purus, quis mollis enim tincidunt ut. Praesent vitae lacus ligula. Aliquam efficitur pharetra mauris, in molestie arcu<br> efficitur ornare. Vivamus sed finibus felis, nec cursus lorem.';
?>
</p>
<?php
}
/*Home Section Content*/
?>
<div class="clear"></div>
<?php
/* Home Four Boxes */
for ($bx = 2; $bx < 6; $bx++) {
if (get_theme_mod('page-setting' . $bx)) {
$bxquery = new WP_query('page_id=' . get_theme_mod('page-setting' . $bx, true));
while ($bxquery->have_posts()) {
$bxquery->the_post();
?>
<a href="<?php
the_permalink();
?>
"><div class="feature-box">
<?php
the_post_thumbnail();
?>
<h2><?php
the_title();
?>
</h2>
<?php
开发者ID:Olaf1989,项目名称:Cakes-and-more,代码行数:31,代码来源:header.php
示例13: get_header
/**
* Template Name: Navigation-sub
*/
get_header();
?>
<div id="primary" class="content-area interview">
<main id="main" class="site-main" role="main">
<?php
if (function_exists('dimox_breadcrumbs')) {
dimox_breadcrumbs();
}
?>
<?php
$args = array('post_parent' => 103, 'post_type' => 'page', 'paged' => $paged);
$subpages = new WP_query($args);
if ($subpages->have_posts()) {
$output = '<ul class="menu-event-wrapp">';
while ($subpages->have_posts()) {
$subpages->the_post();
$output .= '<li><div class="thumb"><a href="' . get_permalink() . '">' . get_the_post_thumbnail() . '</a></div></li>';
}
$output .= '</ul>';
}
echo $output;
wp_reset_postdata();
?>
<?php
$title = get_the_title();
$temp = get_cat_ID($title);
if ($title == 'Інтерв’ю') {
开发者ID:Alexander-smirnov,项目名称:infomist,代码行数:31,代码来源:navigation-sub.php
示例14: WP_query
<?php
if (is_front_page() && !is_home()) {
?>
<section id="wrapsecond" class="pagewrap2">
<div class="container services-wrap">
<?php
for ($p = 1; $p < 5; $p++) {
?>
<?php
if (get_theme_mod('page-column' . $p, false)) {
?>
<?php
$queryxxx = new WP_query('page_id=' . get_theme_mod('page-column' . $p, true));
?>
<?php
while ($queryxxx->have_posts()) {
$queryxxx->the_post();
?>
<div class="listpages <?php
if ($p % 4 == 0) {
echo "last_column";
}
?>
">
<a href="<?php
the_permalink();
开发者ID:beatrixmichella,项目名称:fufyflorist,代码行数:30,代码来源:header.php
示例15: wp_stripe_options_display_trx
/**
* Display Transctions on Options Page
*
* @since 1.0
*
*/
function wp_stripe_options_display_trx()
{
// Paging
function retrievePage()
{
if (!isset($_POST['pagination']) || $_POST['pagination'] == "1") {
$paged = 1;
} else {
$paged = $_POST['pagination'];
}
return intval($paged);
}
// Query Custom Post Types
$args = array('post_type' => 'wp-stripe-trx', 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => 'wp-stripe-date', 'order' => 'DESC', 'posts_per_page' => 10, 'paged' => retrievePage());
// - query -
$my_query = null;
$my_query = new WP_query($args);
while ($my_query->have_posts()) {
$my_query->the_post();
$time_format = get_option('time_format');
// - variables -
$custom = get_post_custom(get_the_ID());
$id = $my_query->post->ID;
$public = $custom["wp-stripe-public"][0];
$live = $custom["wp-stripe-live"][0];
$name = $custom["wp-stripe-name"][0];
$email = $custom["wp-stripe-email"][0];
$content = get_the_content();
$date = $custom["wp-stripe-date"][0];
$cleandate = date('d M', $date);
$cleantime = date('H:i', $date);
$amount = $custom["wp-stripe-amount"][0];
$fee = $custom["wp-stripe-fee"][0] / 100;
$currency = $custom['wp-stripe-currency'][0];
$net = round($amount - $fee, 2);
echo '<tr>';
// Dot
if ($live == 'LIVE') {
$dotlive = '<div class="dot-stripe-live"></div>';
} else {
$dotlive = '<div class="dot-stripe-test"></div>';
}
if ($public == 'YES') {
$dotpublic = '<div class="dot-stripe-public"></div>';
} else {
$dotpublic = '<div class="dot-stripe-test"></div>';
}
// Person
$img = get_avatar($email, 32);
$person = $img . ' <span class="stripe-name">' . $name . '</span>';
// Received
$received = '<span class="stripe-netamount"> + ' . $net . '</span> ' . $currency . ' (-' . $fee . ')';
// Content
echo '<td>' . $dotlive . $dotpublic . '</td>';
echo '<td>' . $person . '</td>';
echo '<td>' . $received . '</td>';
echo '<td>' . $cleandate . ' - ' . $cleantime . '</td>';
echo '<td class="stripe-comment">"' . $content . '"</td>';
echo '</tr>';
}
?>
</table>
<div style="clear:both"></div>
<?php
function totalPages($transactions)
{
// get total pages
if ($transactions > 0) {
$totalpages = floor($transactions / 10) + 1;
} else {
return;
}
return $totalpages;
}
$currentpage = retrievePage();
$totalpages = totalPages($my_query->found_posts);
if ($currentpage > 1) {
echo '<form method="POST" class="pagination">';
echo '<input type="hidden" name="pagination" value="' . (retrievePage() - 1) . '" />';
echo '<input type="submit" value="Previous 10" />';
echo '</form>';
}
if ($currentpage < $totalpages) {
echo '<form method="POST" class="pagination">';
echo '<input type="hidden" name="pagination" value="' . (retrievePage() + 1) . '" />';
echo '<input type="submit" value="Next 10" />';
echo '</form>';
}
echo ' <div style="clear:both"></div>';
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:99,代码来源:stripe-options-transactions.php
示例16: search_everything_callback
function search_everything_callback()
{
$is_query = !empty($_GET['s']);
$result = array();
if ($is_query) {
$result = array('own' => array(), 'external' => array());
$params = array('s' => $_GET['s']);
$zemanta_response = se_api(array('method' => 'zemanta.suggest', 'return_images' => 0, 'return_rich_objects' => 0, 'return_articles' => 1, 'return_markup' => 0, 'return_rdf_links' => 0, 'return_keywords' => 0, 'careful_pc' => 1, 'interface' => 'wordpress-se', 'format' => 'json', 'emphasis' => $_GET['s'], 'text' => $_GET['text']));
if (!is_wp_error($zemanta_response) && $zemanta_response['response']['code'] == 200) {
$result['external'] = json_decode($zemanta_response['body'])->articles;
}
$SE = new SearchEverything(true);
if (!empty($_GET['exact'])) {
$params['exact'] = true;
}
$params["showposts"] = 5;
$post_query = new WP_query($params);
while ($post_query->have_posts()) {
$post_query->the_post();
$result['own'][] = get_post();
}
$post_query->reset_postdata();
}
print json_encode($result);
die;
}
开发者ID:jimmyshen007,项目名称:webproject,代码行数:26,代码来源:search-everything.php
示例17: widget
function widget($args, $instance)
{
extract($args);
$selected_category = $instance["selected_category"];
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
$icon_type = $instance["icon_type"];
$cat_icon_url = $instance["cat_icon_url"];
$post_style = $instance["post_style"];
$post_thumbnail_size = $instance['post_thumbnail_size'];
$this->post_excerpt_length = $instance['post_excerpt_length'];
$number_of_posts = $instance["number_of_posts"];
$icon_height = $instance['icon_height'];
$icon_width = $instance['icon_width'];
$all_posts_text = $instance['all_posts_text'];
$order = isset($instance['order']) ? $instance['order'] : 'DESC';
$order_by = isset($instance['order_by']) ? $instance['order_by'] : 'date';
$ignore_sticky = isset($instance['ignore_sticky']) ? $instance['ignore_sticky'] : 'ignore';
$post_ids = isset($instance['post_ids']) ? $instance['post_ids'] : '';
$tags = isset($instance['tags']) ? $instance['tags'] : '';
$post_formats = isset($instance['post_formats']) ? $instance['post_formats'] : '';
$any_post_type = isset($instance['any_post_type']) ? $instance['any_post_type'] : false;
$separate_widgets = isset($instance['separate_widgets']) ? $instance['separate_widgets'] : false;
$ret = "";
if ($icon_type == 'plugin') {
if (function_exists('get_cat_icon')) {
$cat_icon = get_cat_icon('echo=false&cat=' . $selected_category);
if (trim($cat_icon) != '') {
$ret .= "\t\t<div class='suf-cat-posts-widget-image' style='height: {$icon_height};'>";
$ret .= $cat_icon;
$ret .= "</div>\n";
}
}
} else {
if ($icon_type == 'custom') {
if (trim($cat_icon_url) != '') {
$ret .= "\t\t<div class='suf-cat-posts-widget-image' style='height: {$icon_height};'>";
$ret .= "<a href='" . get_category_link($selected_category) . "'>";
$ret .= "<img src='{$cat_icon_url}' alt='" . esc_attr($title) . "' title='" . esc_attr($title) . "' style='width: {$icon_width}; height: {$icon_height};'/>";
$ret .= "</a>\n";
$ret .= "</div>\n";
}
}
}
$query_args = array('posts_per_page' => $number_of_posts, 'order' => $order, 'orderby' => $order_by);
$tax_query = array('relation' => 'AND');
if ($selected_category != '0' && $selected_category != 0) {
$query_args['cat'] = $selected_category;
$cat_tax = array('taxonomy' => 'category', 'field' => 'id', 'terms' => array($selected_category), 'operator' => 'IN');
}
$post_in = array();
if (trim($post_ids) != '') {
$solo_posts = preg_replace('/\\s\\s+/', ' ', $post_ids);
$solo_posts = explode(',', $solo_posts);
if (count($solo_posts) > 0) {
$post_in = $solo_posts;
}
}
if ($ignore_sticky == 'ignore') {
$query_args['ignore_sticky_posts'] = true;
} else {
if ($ignore_sticky == 'only-sticky') {
$post_in = get_option('sticky_posts');
} else {
$query_args['ignore_sticky_posts'] = false;
}
}
if (is_array($post_in) && count($post_in) > 0) {
$query_args['post__in'] = $post_in;
}
if (trim($tags) != '') {
$solo_tags = preg_replace('/\\s\\s+/', ' ', $tags);
if (count($solo_tags) > 0) {
$query_args['tag'] = $solo_tags;
}
}
if ($post_formats != '') {
$format_tax = array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array("post-format-{$post_formats}"), 'operator' => 'IN');
}
if (isset($cat_tax) && isset($format_tax)) {
$tax_query[] = $cat_tax;
$tax_query[] = $format_tax;
unset($query_args['cat']);
$query_args['tax_query'] = $tax_query;
} else {
if (isset($cat_tax) || isset($format_tax)) {
unset($query_args['cat']);
$tax_query = array(isset($cat_tax) ? $cat_tax : $format_tax);
$query_args['tax_query'] = $tax_query;
}
}
if ($any_post_type) {
$query_args['post_type'] = 'any';
}
$query = new WP_query($query_args);
if (isset($query->posts) && is_array($query->posts) && count($query->posts) > 0 && !($separate_widgets && ($post_style == 'thumbnail-full' || $post_style == 'thumbnail-excerpt'))) {
if ($post_style == 'magazine') {
$ret .= "<ul class='suf-cat-posts-list'>\n";
} else {
if ($post_style == 'thumbnail' || $post_style == 'thumbnail-excerpt' || $post_style == 'thumbnail-full') {
$ret .= "<ul class='suf-posts-thumbnail'>\n";
//.........这里部分代码省略.........
开发者ID:jpsutton,项目名称:suffusion,代码行数:101,代码来源:suffusion-query-posts.php
示例18: get_the_permalink
<?php
$main_permalink = get_the_permalink();
$userlog = is_user_logged_in();
// Status query
$status = new WP_query(array('post_type' => 'status', 'posts_per_page' => 3));
$i = 0;
while ($status->have_posts()) {
$status->the_post();
$comments = get_comments(array('post_id' => get_the_ID(), 'orderby' => 'post_date', 'order' => 'ASC'));
$comment_count = 0;
foreach ($comments as $c) {
$comment_count++;
}
$special_class = '';
$i++;
if ($i === 1) {
$special_class = ' first';
}
?>
<div class="status-container<?php
echo $special_class;
?>
">
<h4><?php
the_title();
?>
</h4>
<div class="status-posts">
<div class="status-post-count">
<a href="#" class="status-post-count-show-all"><?php
开发者ID:JeppeSigaard,项目名称:faaborggym,代码行数:31,代码来源:status-main.php
示例19: array
<img src="https://opengovernment.org.au/wp-content/uploads/2016/02/Australia-Letter-of-Intent-120x120.png" alt="Photograph of Prime Minister Malcoln Turnbull’s letter to the OGP 25 November 2015"/>
<p>In late November 2015 Prime Minister Turnbull wrote to
the OGP renewing Australia’s commitment to membership.</p>
<p>
<a class="btn btn-default" href="https://opengovernment.org.au/2015/11/28/the-prime-ministers-letter-reconfirms-australias-commitment-to-ogp/" title="The Prime Ministers letter reconfirms Australia’s commitment to OGP">
View the letter
</a>
</p>
</div>
</div>
</div><!-- #home-introduction -->
<?php
/* Hardcoded page id :S */
$args = array('p' => 2900, 'post_type' => 'page');
$my_query = new WP_query($args);
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<div class="band" id="draft-plan-released">
<div class="row wide-gutter-row">
<div class="col-sm-12 wide-gutter-col">
<h2><?php
the_title();
?>
</h2>
<?php
the_content();
?>
</div>
</div>
开发者ID:AOGPN,项目名称:opengovernment.org.au,代码行数:31,代码来源:page-home.php
示例20: get_header
<?php
get_header();
?>
<div class="rightSide">
<main class="portfolio">
<div class="wrapper">
<h4 class="animated fadeIn">My Work</h4>
<ul class="portfolioItems">
<?php
$portfolio = new WP_query(array('post_type' => 'portfolio'));
?>
<?php
if ($portfolio->have_posts()) {
?>
<?php
while ($portfolio->have_posts()) {
$portfolio->the_post();
?>
<li class="animated fadeIn">
<div class="portfolioItem">
<div class="portfolioImage">
<?php
the_post_thumbnail('portfolio');
?>
</div>
开发者ID:amiephipps,项目名称:amiephippswp,代码行数:31,代码来源:archive-portfolio.php
注:本文中的WP_query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论