This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> | |
<option value=""><?php echo esc_attr('Выберите событие'); ?></option> | |
<?php | |
$categories= get_categories('child_of=10'); | |
foreach ($categories as $category) { | |
$option = '<option value="/category/archives/'.$category->category_nicename.'">'; | |
$option .= $category->cat_name; | |
$option .= ' ('.$category->category_count.')'; | |
$option .= '</option>'; | |
echo $option; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$categories = get_categories('child_of=8&hide_empty=0');; | |
//echo var_dump($categories); | |
foreach ($categories as $category) { | |
echo $category->name ; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// добавляет вызов функции при инициализации административного раздела | |
add_action('admin_init', 'category_custom_fields', 1); | |
// функция расширения функционала административного раздела | |
function category_custom_fields() | |
{ | |
// добавления действия после отображения формы ввода параметров категории | |
add_action('edit_category_form_fields', 'category_custom_fields_form'); | |
// добавления действия при сохранении формы ввода параметров категории | |
add_action('edited_category', 'category_custom_fields_save'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*functions.php*/ | |
// добавляет вызов функции при инициализации административного раздела | |
add_action('admin_init', 'category_custom_fields', 1); | |
// функция расширения функционала административного раздела | |
function category_custom_fields() | |
{ | |
// добавления действия после отображения формы ввода параметров категории | |
add_action('edit_category_form_fields', 'category_custom_fields_form'); | |
// добавления действия при сохранении формы ввода параметров категории | |
add_action('edited_category', 'category_custom_fields_save'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (have_posts()) : query_posts ( ['cat' => $cat_id, 'meta_key' => 'post_sort_num', 'orderby' => 'meta_value_num', 'order' => 'ASC' ])?> | |
<?php while (have_posts()) : the_post(); ?> | |
<div class="col-md-4 column"> | |
<div class="service-block"> | |
<div class="service-image"> | |
<?php echo the_post_thumbnail( [355,148] ); ?> | |
<i class="fa <?php echo get_post_meta($post->ID,'font_awesome',true) ?>"></i> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="col-md-4 column"> | |
<div class="service-block"> | |
<?php | |
$post = get_post_by_slug('reabilitatsiya-v-tsentre'); | |
$post_id = $post -> ID; | |
?> | |
<div class="service-image"> | |
<?php echo get_the_post_thumbnail( $post_id, [355,148] ); ?> | |
<i class="fa fa-codepen"></i> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Отображение главной страницы | |
home.php | |
index.php | |
Отображение Главной страницы | |
front-page.php - Используется для страниц Ваши последние записи или Статическая страница как выбор в пункте меню Статическая главная страница раздела Внешний вид -> Настроить | |
Page display rules - Когда в разделе Внешний вид -> Настроить в пункте меню Статическая главная страница выбрана Статическая страница | |
Home Page display rules - Когда в разделе Внешний вид -> Настроить в пункте меню Статическая главная страница выбраны Ваши последние записи | |
Отображение одиночной записи |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post Object properties | |
Property Sample Value Notes | |
ID 432 Post ID | |
post_author 1 Post author's user number | |
post_date 2008-03-15 19:22:29 | |
post_date_gmt 2008-03-16 02:22:29 GMT = Greenwich Mean Time | |
post_content Actual post content, including markup | |
post_title Post title | |
post_category 0 Number representing post category ID# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo get_cat_name($cat_id); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Пример цикла на основе get_posts(). Выведем 5 записей из рубрики 9: | |
<?php | |
global $post; // не обязательно | |
$args = array('category' => 9); // 5 записей из рубрики 9 | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ){ setup_postdata($post); | |
// стандартный вывод записей | |
} | |
wp_reset_postdata(); // сбрасываем переменную $post | |
?> |
OlderNewer