function searchExcludePages($query) {
if ($query->is_search) {
$terms = get_terms( array( 'taxonomy' => 'ait-dir-item-category' ) );
$to_exclude = array();
foreach ( $terms as $term ) {
$to_exclude[] = $term->term_id;
}
$tax_query = array(
array(
'taxonomy' => 'ait-dir-item-category',
'terms' => $to_exclude,
'operator' => 'NOT IN'
)
);
$query->set('tax_query', $tax_query);
}
}
add_filter('pre_get_posts','searchExcludePages');
<?php
global $post;
// load all 'category' terms for the post
$terms = get_the_terms($post->ID, 'pro');
// we will use the first term to load ACF data from
if( !empty($terms) )
{
foreach($terms as $term) {
$term_link = get_term_link( $term );
$custom_field = get_field('picon', $term ); ?>
<a href="<?php echo $term_link ?>"><img style="float: left; padding-right: 15px;" src="<?php echo $custom_field; ?>" class="img-circle img-responsive align-center prep" />
</a><h3><?php echo $term->name; ?></h3>
<?php the_field('pnum', $term); ?>
<?php // do something with $custom_field
}
} ?>
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('posts_per_page', '1' );
}
}
}
add_action('pre_get_posts','search_filter');
перебрасывает на главную страницу
<?php
$args = array(
'numberposts' => 8,
'category' => 13,
);
$posts = get_posts( $args );
if($posts) {
foreach($posts as $post){ setup_postdata($post);
?>
<li class="fadeIn wow" data-wow-offset="20"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
}
} else { ?>
Нет записей
<?php }
wp_reset_query();
?>
<?php
if ( have_posts() ) : // если имеются записи в блоге.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_content();
endwhile; // завершаем цикл.
endif;
?>
/wp-admin/post.php?post=8&action=edit
.<?php global $post;
$post = get_post(8);
setup_postdata($post); ?>
<div><?php the_content(); ?></div>
<?php wp_reset_query(); ?>
function my_theme_add_editor_styles() {
add_editor_style();
}
add_action( 'init', 'my_theme_add_editor_styles' );