<meta name="robots" content="follow, index">
Можно ли привязать wordpress сайт(отдельностоящий) к wordpress.com?
function get_categories_tree(string $taxonomy = 'category'): array
{
$terms = get_terms([
'taxonomy' => $taxonomy,
'parent' => false,
'hide_empty' => false,
]);
if (empty($terms) || $terms instanceof WP_Error) {
return [];
}
$categories = [];
foreach ($terms as $term) {
$categories[] = (object) [
'value' => $term->term_id,
'name' => $term->name,
'children' => get_children_categories($term->term_id, $category_id),
];
}
return $categories;
}
function get_children_categories(int $parent_term_id, int $category_id): array
{
$children = array();
$child_terms = get_terms([
'taxonomy' => 'category',
'parent' => $parent_term_id,
'hide_empty' => false,
]);
foreach ($child_terms as $child_term) {
$child = (object) [
'term_id' => $child_term->term_id,
'name' => $child_term->name,
'value' => $child_term->term_id,
];
$grandchildren = get_children_categories($child_term->term_id, $category_id);
if (!empty($grandchildren)) {
$child->children = $grandchildren;
}
$children[] = $child;
}
return $children;
}
$list = get_categories_tree();
span
с background-image
.div
<div id="test-answer">
<h3 id="test-answer-text">Здесь находится какой-то вопрос, который должен адаптивно вписаться в определенные
границы</h3>
<div id="test-answer-price">
<img src="/assets/coin.png" id="test-answer-price-img" />
<span>15</span>
</div>
</div>
wp_nav_menu([
'theme_location' => 'top_left',
'container'=> false,
'items_wrap' => '<ul class="nav navbar-nav %2$s">%3$s</ul>',
'menu_class' => '',
'ul_class' => 'navbar-nav',
'ul_child_class' => 'dropdown-menu',
'li_class' => 'nav-item',
'li_child_class' => 'nav-item',
'a_class' => 'nav-link',
'a_child_class' => 'nav-link',
]);
## Добавление стилей для стандартного меню
add_filter('nav_menu_css_class', 'add_menu_list_item_class', 1, 3);
function add_menu_list_item_class($classes, $item, $args) {
if (property_exists($args, 'li_class') && !$item->menu_item_parent) {
$classes[] = $args->li_class;
}
if (property_exists($args, 'li_child_class') && $item->menu_item_parent) {
$classes[] = $args->li_child_class;
}
return $classes;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );
function add_menu_link_class( $atts, $item, $args ) {
if ( strpos( $atts['href'], home_url() ) === false ) {
$atts['target'] = '_blank';
}
if (property_exists($args, 'a_class') && !$item->menu_item_parent) {
$atts['class'] = $args->a_class;
}
if (property_exists($args, 'a_child_class') && $item->menu_item_parent) {
$atts['class'] = $args->a_child_class;
}
return $atts;
}
add_filter( 'nav_menu_submenu_css_class', 'my_nav_menu_submenu_css_class', 1, 3);
function my_nav_menu_submenu_css_class($classes, $args, $depth) {
if (property_exists($args, 'ul_child_class')) {
$classes[] = $args->ul_child_class;
}
return $classes;
}