本文整理汇总了PHP中ap_get_questions函数的典型用法代码示例。如果您正苦于以下问题:PHP ap_get_questions函数的具体用法?PHP ap_get_questions怎么用?PHP ap_get_questions使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ap_get_questions函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
public function widget($args, $instance)
{
global $questions;
$title = apply_filters('widget_title', $instance['title']);
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo '<div class="ap-widget-inner">';
if (!class_exists('Tags_For_AnsPress')) {
echo 'Tags plugin must be installed for related question. Get <a href="https://wordpress.org/plugins/tags-for-anspress">Tags for AnsPress</a>';
return;
}
$tags = get_the_terms(get_question_id(), 'question_tag');
$tags_in = array();
if ($tags) {
foreach ($tags as $t) {
$tags_in[] = $t->term_id;
}
}
$question_args = array('tax_query' => array(array('taxonomy' => 'question_tag', 'field' => 'term_id', 'terms' => $tags_in)), 'showposts' => 5, 'post__not_in' => array(get_question_id()));
$questions = ap_get_questions($question_args);
include ap_get_theme_location('widget-related_questions.php');
wp_reset_postdata();
echo '</div>';
echo $args['after_widget'];
}
示例2: widget
public function widget($args, $instance)
{
global $questions;
$title = apply_filters('widget_title', $instance['title']);
$sort = $instance['sort'];
$limit = $instance['limit'];
$category_ids = $instance['category_ids'];
if (!empty($category_ids)) {
$category_ids = explode(',', str_replace(' ', '', $category_ids));
}
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
$question_args = array('showposts' => $limit, 'sortby' => $sort);
if (is_array($category_ids) && count($category_ids) > 0) {
$question_args['tax_query'][] = array('taxonomy' => 'question_category', 'field' => 'term_id', 'terms' => $category_ids);
}
$questions = ap_get_questions($question_args);
echo '<div class="ap-widget-inner">';
ap_get_template_part('widget-questions');
echo '</div>';
echo $args['after_widget'];
wp_reset_postdata();
}
示例3: widget
public function widget($args, $instance)
{
$title = apply_filters('widget_title', $instance['title']);
$order = $instance['order'];
$limit = $instance['limit'];
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
$question_args = array('showposts' => $limit, 'orderby' => $order);
$questions = ap_get_questions($question_args);
ap_get_template_part('widget-questions');
echo $args['after_widget'];
wp_reset_postdata();
}
示例4: questions_page
/**
* Output for user questions page
* @since 2.1
*/
public function questions_page()
{
global $questions;
$questions = ap_get_questions(array('author' => ap_get_displayed_user_id()));
ap_get_template_part('user/user-questions');
wp_reset_postdata();
}
示例5: subscription_page
/**
* Register user subscription page
* @since 2.3
*/
public function subscription_page()
{
global $questions;
if (!ap_is_user_page_public('profile') && !ap_is_my_profile()) {
ap_get_template_part('not-found');
return;
}
$questions = ap_get_questions(array('ap_query' => 'ap_subscription_query', 'user_id' => get_current_user_id(), 'sortby' => 'newest'));
ap_get_template_part('user/subscription');
}
示例6: category_page
public function category_page()
{
global $questions, $question_category;
$category_id = sanitize_text_field(get_query_var('q_cat'));
$question_args = array('tax_query' => array(array('taxonomy' => 'question_category', 'field' => is_numeric($category_id) ? 'id' : 'slug', 'terms' => array($category_id))));
$question_category = get_term_by(is_numeric($category_id) ? 'id' : 'slug', $category_id, 'question_category');
$questions = ap_get_questions($question_args);
include ap_get_theme_location('category.php', CATEGORIES_FOR_ANSPRESS_DIR);
}
示例7: tag_page
public function tag_page()
{
global $questions, $question_tag;
$tag_id = sanitize_text_field(get_query_var('q_tag'));
$question_args = array('tax_query' => array(array('taxonomy' => 'question_tag', 'field' => is_numeric($tag_id) ? 'id' : 'slug', 'terms' => array($tag_id))));
$question_tag = get_term_by(is_numeric($tag_id) ? 'id' : 'slug', $tag_id, 'question_tag');
$questions = ap_get_questions($question_args);
include ap_get_theme_location('tag.php', TAGS_FOR_ANSPRESS_DIR);
}
示例8: _e
</strong>
<span><?php
_e('Flagged', 'ap');
?>
</span>
</a>
</li>
</ul>
</div>
<div class="ap-dash-tile-in ap-dash-questions">
<h3 class="ap-dash-title"><?php
_e('Latest Questions', 'ap');
?>
</h3>
<?php
$questions = ap_get_questions(array('sortby' => 'newest'));
if (ap_have_questions()) {
?>
<div class="ap-user-posts">
<?php
while (ap_questions()) {
ap_the_question();
?>
<div class="ap-user-posts-item clearfix">
<a class="ap-user-posts-vcount ap-tip<?php
echo ap_question_best_answer_selected() ? ' answer-selected' : '';
?>
" href="<?php
ap_question_the_permalink();
示例9: ap_icon
}
?>
</div>
</div>
<div class="ap-about-block top-answers">
<h3><?php
echo ap_icon('question', true);
?>
<?php
_e('New questions', 'ap');
?>
</h3>
<div class="ap-about-block-c">
<?php
$questions = ap_get_questions(array('author' => ap_get_displayed_user_id(), 'showposts' => 5, 'sortby' => 'newest'));
?>
<?php
if (ap_have_questions()) {
?>
<?php
while (ap_questions()) {
ap_the_question();
?>
<?php
ap_get_template_part('user/list-question');
?>
<?php
}
示例10: subscription_page
/**
* Register user subscription page
* @since 2.3
*/
public function subscription_page()
{
if (!ap_is_user_page_public('profile') && !ap_is_my_profile()) {
ap_get_template_part('not-found');
return;
}
ap_get_questions(array('ap_query' => 'ap_subscription_query', 'user_id' => get_current_user_id(), 'sortby' => 'newest'));
include ap_get_theme_location('user/subscription.php');
}
示例11: tag_page
/**
* Tag page layout.
*/
public function tag_page()
{
global $questions, $question_tag;
$tag_id = sanitize_title(get_query_var('q_tag'));
$question_args = array('tax_query' => array(array('taxonomy' => 'question_tag', 'field' => is_numeric($tag_id) ? 'id' : 'slug', 'terms' => array($tag_id))));
$question_tag = get_term_by(is_numeric($tag_id) ? 'id' : 'slug', $tag_id, 'question_tag');
if ($question_tag) {
$questions = ap_get_questions($question_args);
include ap_get_theme_location('tag.php', TAGS_FOR_ANSPRESS_DIR);
} else {
global $wp_query;
$wp_query->set_404();
status_header(404);
include ap_get_theme_location('not-found.php');
}
}
示例12: search_page
/**
* Load search page template
*/
public function search_page()
{
global $questions;
$keywords = sanitize_text_field(get_query_var('ap_s'));
$type = sanitize_text_field(wp_unslash(@$_GET['type']));
if ('' == $type) {
$questions = ap_get_questions(array('s' => $keywords));
include ap_get_theme_location('base.php');
} elseif ('user' == $type && ap_opt('enable_users_directory')) {
global $ap_user_query;
$ap_user_query = ap_has_users(array('search' => $keywords, 'search_columns' => array('user_login', 'user_email', 'user_nicename')));
include ap_get_theme_location('users/users.php');
}
}
示例13: category_page
/**
* Category page layout
*/
public function category_page()
{
global $questions, $question_category, $wp;
$category_id = sanitize_title(get_query_var('q_cat'));
$question_args = array('tax_query' => array(array('taxonomy' => 'question_category', 'field' => is_numeric($category_id) ? 'id' : 'slug', 'terms' => array($category_id))));
$question_category = get_term_by('slug', $category_id, 'question_category');
if ($question_category) {
$questions = ap_get_questions($question_args);
include ap_get_theme_location('category.php', CATEGORIES_FOR_ANSPRESS_DIR);
} else {
global $wp_query;
$wp_query->set_404();
status_header(404);
include ap_get_theme_location('not-found.php');
}
}