register_taxonomy()
<p class="text-decor">another text</p>
<span class="text-decor">another text</span>
p, span {
line-height: 1.25;
}
.text-decor {
position: relative;
}
.text-decor::after {
content: '';
position: absolute;
width: 100%;
max-width: 180px;
height: 50%;
bottom: 0;
left: 0;
background: red;
opacity: 1;
z-index: -1;
}
add_image_size()
в коде вашей темы или плагинаremove_image_size()
the_custom_logo()
add_filter( 'get_custom_logo', 'custom_logo_url' );
function custom_logo_url( $html ) {
if ( is_home() && is_front_page() ) {
$dir = wp_get_upload_dir();
$html = '<img class="logo-main scale-with-grid" src="' . $dir['baseurl'] . '/2021/08/logo-black.png" data-retina="" data-height="93" alt="logo-black" data-no-retina="">';
}
return $html;
}
is_single()
, is_page()
, is_archive()
, is_front_page()
и подобные, чтобы выполнить код для определенного шаблонаwp_get_upload_dir()
получает массив вариаций путей до каталога загрузок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 в качестве примера