robots_txt
. Работает это так:// Добавляем правила для файла robots.txt
add_filter( 'robots_txt', 'custom_robots_txt', 20, 2 );
function custom_robots_txt( $output, $public ) {
$output .= "Disallow: /search/\n";
$output .= "Disallow: /author/\n";
$output .= "Disallow: /users/\n";
return apply_filters( 'custom_robots_txt', $output, $public );
}
if ( $xlsx = SimpleXLSX::parse('book.xlsx') ) {
print_r( $xlsx->rows() );
} else {
echo SimpleXLSX::parseError();
}
if ( $xlsx = SimpleXLSX::parse('book.xlsx') ) {
print_r( $xlsx->rows() );
} else {
echo SimpleXLSX::parseError();
}
get_the_terms()
получает термины, относящиеся к текущей записи. Если у вас отмечены "Бесплатно" и "Государственное", то функция вернет и их. В этой функции нет аргументов, позволяющих исключить термины из выборки на момент запроса в базу$cur_terms = get_the_terms( $postID->ID, 'wpsl_store_category' );
$not_allowed = [ 'Бесплатно', 'Государственное' ];
if( is_array( $cur_terms ) ) {
foreach( $cur_terms as $cur_term ) {
if ( !in_array( $cur_term->name, $not_allowed ) ) {
echo $cur_term->name;
}
}
}
add_action( 'admin_init', 'razreshit_uchasnikam_gruzit_faili' );
function razreshit_uchasnikam_gruzit_faili() {
if ( !current_user_can( 'upload_files' ) ) :
$uchasnik = get_role( 'author' );
$uchasnik->add_cap( 'upload_files' );
endif;
}
wp_query()
НЕ НУЖНО. Если нужно изменить запрос, то делать это нужно на хуке pre_get_posts
the_posts_pagination()
и the_posts_navigation()
, я советую посмотреть любую популярную или стандартную тему twenty в качестве примераif ( get_post_type() === 'post' ) {
# code...
}
if ( is_category( [ 'news', 'projects' ] ) || ( is_singular( 'post' ) && has_category( [ 'news', 'projects' ] ) ) ) {
# code...
}