Эта страница сделана для себя, чтобы всегда было под рукой то, что может потребоваться, так как записи ведутся с 2012 года, что-то может быть уже не актуально :)
Ошибка http при загрузке файла - помогла смена версии PHP на хостинге с 5.6 на 5.5
Не уходят оповещения о заказе - отправляются письма только с доменного адреса почты (ящик@домен)
/wp-admin/options.php
1 2 | {position:relative;} /*добавляется у родительского блока, чтобы отсчет шел именно с него.*/ {width: 920px; position:absolute; left:50%; margin-left:-460px;} /*920:2=460*/ |
^= начинается
$= оканчивается
*= содержит
1 | section[id^="text-"] div.textwidget {padding: 0 10px;} |
1 2 | ul.fll_spisok {list-style: url(/wp-content/uploads/spisok.png) outside; margin-left: 45px;} ul.fll_spisok li span {position: relative; bottom: 8px;} |
1 2 3 4 5 | display: block; /*?*/ -webkit-box-sizing:content-box; -moz-box-sizing:content-box; -ms-box-sizing:content-box; box-sizing:content-box; |
1 2 3 | form#order select {margin-left: 16px; width: 280px; padding: 12px 16px 11px 16px; line-height: 25px; font-size: 14px; color: #40291A; background-color: #FAF6F2; background-image: url('/wp-content/uploads/2018/12/select-fon.png'); background-position: 95% center; background-repeat: no-repeat; border: 0; -webkit-appearance: none; -moz-appearance: none; text-indent: 0.01px; text-overflow: ''; -ms-appearance: none; appearance: none!important;} select::-ms-expand {display: none;} form#order select:hover {cursor: pointer; opacity: .7;} |
1 2 3 4 5 6 7 8 9 10 11 | <?php $phone = get_theme_mod('lf_call'); $phone_tel = preg_replace('/[^0-9]/', '', $phone); //0123456789 ?> <a href="tel:<?php echo "$phone_tel"; ?>"><?php echo "$phone"; ?></a> <?php $phone = get_theme_mod('lf_call'); $phone_tel = preg_replace('/[^+\d]+/ism', '', $phone); //+0123456789 ?> <a href="tel:<?php echo "$phone_tel"; ?>"><?php echo "$phone"; ?></a> |
1 2 3 4 5 6 7 8 9 10 11 12 13 | <a title="Позвонить" href="tel:+120345678910">+12(034)567-89-10</a> <a title="WhatsApp" href="whatsapp://send?phone=+120345678910">WhatsApp</a> //Для приложения Viber на ПК <a title="Viber" href="viber://chat?number=+120345678910">Viber</a> //Для приложения Viber на мобильных <a title="Viber" href="viber://add?number=120345678910">Viber</a> <a title="Telegram" href="tg://resolve?domain=nikname">Telegram</a> <a href="skype:nikname?chat">nikname</a> <a href="skype:nikname?call">Skype</a> |
1 | #lf_1a {display: block; margin-top: -110px; padding-top: 110px;} |
1 2 3 4 5 6 | @keyframes mayachok { 0% { background-color: rgba(238,238,34,0);} 50% { background-color: rgba(238,238,34,0.5);} 100% { background-color: rgba(238,238,34,0);} } .primary-menu #menu-item-333 a {animation: mayachok 1500ms ease-in-out infinite;} |
1 2 3 | @media screen and (max-width: 780px) { .site-title {font-size: 16px;} } |
1 2 3 4 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> заменить на <meta name="viewport" content="width=1263"> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // Отменяем srcset // выходим на раннем этапе, этот фильтр лучше чем 'wp_calculate_image_srcset' add_filter('wp_calculate_image_srcset_meta', '__return_null' ); // Отменяем sizes - это поздний фильтр, но раннего как для srcset пока нет... add_filter('wp_calculate_image_sizes', '__return_false', 99 ); // Удаляем фильтр, который добавляет srcset ко всем картинкам в тексте записи remove_filter('the_content', 'wp_make_content_images_responsive' ); // Очищаем атрибуты из wp_get_attachment_image(), если по каким-то причинам они там остались... add_filter('wp_get_attachment_image_attributes', 'unset_attach_srcset_attr', 99 ); function unset_attach_srcset_attr( $attr ){ foreach( array('sizes','srcset') as $key ) if( isset($attr[ $key ]) ) unset($attr[ $key ]); return $attr; } |
1 2 3 4 5 6 | <meta name="viewport" id="viewport" content="width=1263"> <script type='text/javascript'> if (screen.width <= 480) { document.getElementById("viewport").setAttribute("content", "width=480"); } </script> |
1 2 3 4 5 | <?php if (wp_is_mobile()): ?> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php else: ?> <meta name="viewport" content="width=1263"> <?php endif; ?> |
1 2 3 4 5 6 7 | function mobil_no_content($atts, $content = null) { if (wp_is_mobile() && !is_null($content)){ return ''; } return do_shortcode($content); } add_shortcode( 'nomobil', 'mobil_no_content'); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function lf_noiPhone_content($atts, $content = null) { if( preg_match('/iPhone|iPad|iPod/i', $_SERVER ['HTTP_USER_AGENT']) ){ return ''; } return do_shortcode($content); } add_shortcode( 'lfnoiPhone', 'lf_noiPhone_content'); function lf_iPhone_content($atts, $content = null) { if( !preg_match('/iPhone|iPad|iPod/i', $_SERVER ['HTTP_USER_AGENT']) ){ return ''; } return do_shortcode($content); } add_shortcode( 'lfiPhone', 'lf_iPhone_content'); |
1 2 3 4 5 6 7 8 9 | <video poster="/wp-content/uploads/video-poster.jpg" controls="controls" width="100%" height="auto"> <source src="/wp-content/uploads/video.ogv" type="video/ogg" /> <source src="/wp-content/uploads/video.mp4" type="video/mp4" /> </video> <video controls="controls" width="100%" height="auto"> <source src="/wp-content/uploads/video.ogv" type="video/ogg" /> <source src="/wp-content/uploads/video.mp4" type="video/mp4" /> </video> |
youtube во всю ширину:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | .video { position: relative; padding-bottom: 56.25%; height: 0; } .video iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } <div class="video"><iframe src="https://www.youtube.com/embed/8tTssv6Fi7s?rel=0" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div> |
youtube автоплей:
1 | <div class="video"><iframe src="https://www.youtube.com/embed/dCCi-FExoVk?rel=0&autoplay=1&loop=1&playlist=dCCi-FExoVk" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div> |
Создание шорткода:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | function display_latest_post($atts) { // Получаем значения атрибутов // если значения не были указаны определяем свои extract( shortcode_atts( array( 'numberofpost' => '3', // количество запрашиваемых записей 'categoryid' => '', // id категории ), $atts ) ); // объявляем переменную для возврата $result = ''; // формируем текст запроса $querystring = 'posts_per_page='.$numberofpost; if(strlen($categoryid) > 0) $querystring .= '&cat='.$categoryid; // выполняем запрос $query = new WP_Query( $querystring ); // Цикл, пока есть записи while ( $query->have_posts() ) : $query->the_post(); // формируем список $result.= '<li>'; $result.= '<a href="'.get_permalink().'">'.get_the_title().'</a>'; $result.= '</li>'; endwhile; // После цикла, восстанавливаем текущую запись в $post wp_reset_postdata(); // Возвращаем результат - список return $result; } // регистрируем шорткод add_shortcode( 'dlp', 'display_latest_post' ); |
Вывод шорткода в шаблоне:
1 2 | echo do_shortcode('[shortcode_name]'); echo do_shortcode('[iscorrect]'. $text_to_be_wrapped_in_shortcode .'[/iscorrect]'); |
Если шорткод не работает в виджете:
1 | add_filter( 'widget_text', 'do_shortcode' ); |
Ноги растут из \wp-includes\default-filters.php, отключение этих фильтров:
1 2 3 4 5 | remove_filter('pre_term_name', 'wp_filter_kses'); remove_filter('pre_term_name', 'sanitize_text_field'); remove_filter('pre_term_name', '_wp_specialchars', 30); remove_filter('single_cat_title', 'strip_tags'); remove_filter('pre_term_description', 'wp_filter_kses'); |
в function.php:
1 | require_once( get_template_directory() .'/functions/widgets/widget-xxx.php' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <?php $loop = new WP_Query( array( 'post_type' => array('svoy_tip_posta')) ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <article> <div class="post"> <div class="content"> <a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></h1></a> <div>от <?php the_author_posts_link(); ?></div> </div> <div> <?php the_excerpt('...'); ?> </div> <div><a href="<?php the_permalink(); ?>">Читать всю статью</a></div> </div> </article> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?> |
1 2 3 4 5 6 7 | <?php $loop = new WP_Query( 'category_name=home-uslugi' ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | add_action( 'init', 'true_register_post_type_init' ); function true_register_post_type_init() { $labels = array( 'name' => 'Новости', 'singular_name' => 'Новость', // админ панель Добавить->Функцию 'add_new' => 'Добавить Новость', 'add_new_item' => 'Добавить новую Новость', // заголовок тега <title> 'edit_item' => 'Редактировать Новость', 'new_item' => 'Новая Новость', 'all_items' => 'Все Новости', 'view_item' => 'Просмотр Новостей на сайте', 'search_items' => 'Искать Новости', 'not_found' => 'Новостей не найдено.', 'not_found_in_trash' => 'В корзине нет Новостей.', 'menu_name' => 'Новости' // ссылка в меню в админке ); $args = array( 'labels' => $labels, 'public' => true, 'show_ui' => true, // показывать интерфейс в админке 'has_archive' => true, 'menu_position' => 5, // порядок в меню 'supports' => array( 'title', 'editor', 'comments', 'author', 'thumbnail'), 'taxonomies' => array( 'rubrika_news' ) ); register_post_type('news', $args); } add_action( 'init', 'create_news_taxonomies', 0 ); function create_news_taxonomies(){ $labels = array( 'name' => _x( 'Рубрики', 'taxonomy general name' ), 'singular_name' => _x( 'Рубрики', 'taxonomy singular name' ), 'search_items' => __( 'Искать Рубрики' ), 'popular_items' => __( 'Популярные Рубрики' ), 'all_items' => __( 'Все Рубрики' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Править Рубрику' ), 'update_item' => __( 'Обновить Рубрику' ), 'add_new_item' => __( 'Добавить новую Рубрику' ), 'new_item_name' => __( 'Имя новой Рубрики' ), 'separate_items_with_commas' => __( 'Separate writers with commas' ), 'add_or_remove_items' => __( 'Добавить или удалить Рубрику' ), 'choose_from_most_used' => __( 'Choose from the most used writers' ), 'menu_name' => __( 'Рубрики' ), ); register_taxonomy('rubrika_news', 'articles',array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'rubrika_news' ), )); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // Добавляем рубрики function wptp_add_categories_to_attachments() { register_taxonomy_for_object_type( 'category', 'attachment' ); } add_action( 'init' , 'wptp_add_categories_to_attachments' ); // Добавляем метки function wptp_add_tags_to_attachments() { register_taxonomy_for_object_type( 'post_tag', 'attachment' ); } add_action( 'init' , 'wptp_add_tags_to_attachments' ); // Вводим новую таксономию «Места» для медиафайлов function wptp_add_location_taxonomy() { $labels = array( 'name' => 'Места', 'singular_name' => 'Location', 'search_items' => 'Поиск мест', 'all_items' => 'Все места', 'parent_item' => 'Родительское место', 'parent_item_colon' => 'Родительское место:', 'edit_item' => 'Редактировать место', 'update_item' => 'Обновить место', 'add_new_item' => 'Добавить новое место', 'new_item_name' => 'Имя нового места', 'menu_name' => 'Места', ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'query_var' => 'true', 'rewrite' => 'true', 'show_admin_column' => 'true', ); register_taxonomy( 'location', 'attachment', $args ); } add_action( 'init', 'wptp_add_location_taxonomy' ); |
fonts-online.ru
fonts.google.com
1 2 3 4 | @font-face { font-family: 'Bad Script'; src: url('/wp-content/uploads/Bad-Script.ttf'); } |
1 2 3 4 | <a title="Позвоните нам" href="tel:+71234567890">8 (1234) 56-78-90</a> <meta name="format-detection" content="telephone=no"> |
1 2 3 4 5 | add_filter( 'get_search_form', 'replace_placeholder' ); function replace_placeholder( $form ) { return str_replace( 'placeholder="Поиск..."', 'placeholder="Ваш текст"', $form ); } |
Добавить в functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | add_action('customize_register', function($customizer){ $customizer->add_section( 'fll_section', array( 'title' => 'Дополнительные настройки', 'description' => 'Почта, телефон, ВКонтакте', 'priority' => 35, ) ); $customizer->add_setting( 'fll_textbox_mail', array( 'default' => 'mail@mail.ru' ) ); $customizer->add_setting( 'fll_textbox_telefon', array( 'default' => '+7-777-777-7777' ) ); $customizer->add_setting( 'fll_textbox_vk', array( 'default' => 'http://vk.com/' ) ); $customizer->add_control( 'fll_textbox_mail', array( 'label' => 'Почта:', 'section' => 'fll_section', 'type' => 'text', ) ); $customizer->add_control( 'fll_textbox_telefon', array( 'label' => 'Телефон:', 'section' => 'fll_section', 'type' => 'text', ) ); $customizer->add_control( 'fll_textbox_vk', array( 'label' => 'ВКонтакте:', 'section' => 'fll_section', 'type' => 'text', ) ); }); |
Вывод:
1 2 3 | <p class="fll-contact"><?php echo get_theme_mod('fll_textbox_telefon'); ?> <a href="#" class="callme_viewform" title="Заказать обратный звонок">Заказать обратный звонок</a></p> <p class="fll-contact"><?php echo get_theme_mod('fll_textbox_mail'); ?> <a href="mailto:<?php echo get_theme_mod('fll_textbox_mail'); ?>" title="Написать письмо"><img src="/wp-content/uploads/mail.png" alt="Написать письмо"></a></a></p> <p class="fll-contact"><a href="<?php echo get_theme_mod('fll_textbox_vk'); ?>" target="_blank" title="Наша страничка ВКонтакте"><img class="fll-vk" src="/wp-content/uploads/vk.png" alt="ВКонтакте"></a></p> |
1 2 3 4 5 6 7 8 9 10 | add_filter( 'get_the_archive_title', function ($title) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = '' . get_the_author() . '' ; } return $title; }); |
или заменить первое на второе:
1 2 3 | the_archive_title( '<h1 class="page-title">', '</h1>' ); echo '<h1 class="page-title">' . single_cat_title( '', false ) . '</h1>'; |
Добавить в конце functions.php:
1 2 3 4 5 | function remove_comment_fields($fields) { unset($fields['url']); return $fields; } add_filter('comment_form_default_fields','remove_comment_fields'); |
Добавить в конце functions.php:
1 | remove_filter('comment_text', 'make_clickable', 9); |
comment_form в comments.php:
1 2 3 4 | <?php comment_form( array( 'title_reply' => 'Написать заявку', 'label_submit' => 'Отправить сообщение' )); ?> |
Добавить в functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function add_comment_fields($fields) { $fields['age'] = '<p class="comment-form-age"><label for="age">' . __( 'Возраст' ) . '</label>' . '<input id="age" name="age" type="text" size="30" /></p>'; return $fields; } add_filter('comment_form_default_fields','add_comment_fields'); function add_comment_meta_values($comment_id) { if(isset($_POST['age'])) { $age = wp_filter_nohtml_kses($_POST['age']); add_comment_meta($comment_id, 'age', $age, false); } } add_action ('comment_post', 'add_comment_meta_values', 1); |
Вывод нового поля в своём списке комментов:
1 | echo "Возраст: ".get_comment_meta( $comment->comment_ID, 'age', true ); |
Создание своего списка комментов, добавить в functions.php:
1 2 3 4 5 6 7 8 9 10 11 | function my_custom_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"> <?php if ($comment->comment_approved == '0') : ?> <em><?php _e('Ваш комментарий ожидает модерации.') ?></em> <?php endif; ?> <!-- разметка комментария --> <p><strong><? echo comment_author_link(); ?></strong> <?php echo "Возраст: ".get_comment_meta( $comment->comment_ID, 'age', true ); ?> <?php _e(' написал ') ?><em><? echo comment_date(); ?> <? echo comment_time(); ?></em></p> <p><? comment_text(); ?></p> <? } |
Вывод своего списка комментов в comments.php:
1 | wp_list_comments("callback=my_custom_comments"); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $args = array( 'number' => 20, 'orderby' => 'comment_date', 'order' => 'DESC', //'post_id' => 0, 'type' => 'comment', 'status' => 'approve', ); if( $comments = get_comments( $args ) ){ echo '<ul>'; foreach( $comments as $comment ){ $comm_link = get_comment_link( $comment->comment_ID ); // может быть тяжелый запрос ... $comm_short_txt = mb_substr( strip_tags( $comment->comment_content ), 0, 100 ) .'...'; $comm_post = get_the_title( $comment->comment_post_ID ); echo '<li><p>'. $comment->comment_author .': <a rel="nofollow" href="'. $comm_link .'">'. $comm_short_txt .'</a><br>Статья: <b>'. $comm_post .'</b></p></li>'; } echo '</ul>'; } |
1 2 | #gallery-1 {text-align: center;} #gallery-1 .gallery-item {float: none; display: inline-block;} |
1 2 3 4 5 6 7 8 9 10 11 | <div class="fll-background"> <img src="/wp-content/uploads/fon.jpg"> </div> .fll-background, .fll-background img { width: 100%; } .fll-background { position: fixed; z-index: -1; } |
1 2 3 4 5 6 7 8 | #container:after { content: " "; display: block; clear: both; visibility: hidden; height: 0; line-height: 0; } |
1 2 3 4 5 | <?php echo get_post_meta($post->ID, 'xxx', true); ?> <?php if (get_post_meta($post->ID, 'xxx', true) !== '') : ?> <?php echo get_post_meta($post->ID, 'xxx', true); ?> <?php endif; ?> |
для шорткода в произвольном поле:
1 2 3 | <?php echo apply_filters('the_content', get_post_meta($post->ID, 'xxx', true)); ?> <?php if (get_post_meta($post->ID, 'xxx', true) !== '') {echo "<p>Xxx: ".get_post_meta($post->ID, 'xxx', true)."</p>"; }?> |
Добавить в конце functions.php:
1 2 3 4 5 6 7 8 | //отключить замену в тексте записей и страниц remove_filter('the_content', 'wptexturize'); //отключить замену в заголовках записей и страниц remove_filter('the_title', 'wptexturize'); //отключить замену в тексте комментариев remove_filter('comment_text', 'wptexturize'); |
1 | <p>Авторские права © <?php echo date('Y'); ?> <a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a> Все права защищены</p> |
Easy FancyBox + Contact Form 7:
1 2 3 4 5 6 | <a href="#contact_form_pop" class="fancybox-inline">Напишите нам</a> <div style="display:none" class="fancybox-hidden"> <div id="contact_form_pop"> [форма] </div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Данные теги будут работать только в контенте поста. Если форма в модальном окне, в сайдбаре, футере или хедере, встроена в шаблон темы, то есть вне контента поста - они не сработают. [_post_id] Будет заменен на ID поста, в контенте которого отображена форма. [_post_name] Будет заменен на имя (slug) поста, с которого была отправлена форма. [_post_title] Будет заменен на название (заголовок) поста, с которого была отправлена форма. [_post_url] Будет заменен на ссылку (url) поста, с которого была отправлена форма. [_post_author] Будет заменен на имя автора поста, с которого была отправлена форма. [_post_author_email] Будет заменен на email автора поста, с которого была отправлена форма. |
вывести только содержимое:
1 | <?php echo (get_post(10)->post_content); ?> |
вывести с шорткодами:
1 | <?php echo apply_filters('the_content', get_post(123)->post_content); ?> |
вывести точно с текущим шаблоном (например: template-parts/content-page.php):
1 2 3 4 | <?php $my_query = new WP_Query('page_id=10'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php get_template_part( 'template-parts/content', 'page' ); ?> <?php endwhile; ?> |
при ЧПУ:
домен/tag/raz+dva/— все записи, в которых есть обе метки: raz и dva
домен/tag/raz,dva/— все записи, в которых хотя бы одна метка: raz или dva
по-умолчанию:
домен/?tag=raz+dva
домен/?tag=raz,dva
Для активации добавить в functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function true_plugins_activate() { if ( $active_plugins = get_option('active_plugins') ) { // вытаскиваем массив с активными плагинами $activate_this = array( // в массиве перечисляем плагины которые хотим включить, путь к файлу плагина относительно папки plugins, о том как его узнать, написано ниже 'hello.php', // например Hello Dolly 'wp-pagenavi/wp-pagenavi.php' // и плагин списка страниц ); foreach ( $activate_this as $plugin ) { if ( ! in_array( $plugin, $active_plugins ) ) { array_push( $active_plugins, $plugin ); update_option( 'active_plugins', $active_plugins ); } } } } add_action( 'admin_init', 'true_plugins_activate', 10 ); |
Для деактивации добавить в functions.php:
1 2 3 4 5 6 7 8 9 10 11 | function true_plugins_deactivate() { if ( $active_plugins = get_option('active_plugins') ) { $deactivate_this = array( // в массиве перечисляем плагины которые хотим деактивировать 'akismet/akismet.php' // например этот плагин от спама ); $active_plugins = array_diff( $active_plugins, $deactivate_this ); update_option( 'active_plugins', $active_plugins ); } } add_action( 'admin_init', 'true_plugins_deactivate', 20 ); |
1 | <?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?> |
1 2 3 4 5 | <?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); $image_url_min = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail'); ?> <a href="<?php echo $large_image_url[0]; ?>"><img src="<?php echo $image_url_min[0]; ?>"/></a> |
1 2 3 4 5 6 7 8 9 10 11 12 13 | $categories = get_terms(array( 'taxonomy' => 'rubrika_literatura', 'parent' => 75, )); foreach ($categories as $cat) { $id = $cat->term_id; $link = get_term_link($id); echo '<div> <h1><a href="'.$link.'" title="'.$cat->name.'">'.$cat->name.'</a></h1> <p>'.$cat->description.'</p> <a href="'.$link.'" title="'.$cat->name.'">Подробнее</a> </div>'; } |
1 2 3 4 5 6 7 | <?php if( is_single(array(1311,1313,1315)) ) : ?> <?php else : ?> <?php endif; ?> <?php if( in_category(9) ) : ?> <?php else : ?> <?php endif; ?> |
1 2 | query_posts($query_string.'&orderby=title&order=asc'); while ( have_posts() ) : the_post(); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <?php $category = get_queried_object()->term_id; $paged = (get_query_var('paged')) ? get_query_var('paged'): 1; $order = "&orderby=date&order=DESC&paged=$paged&cat=$category"; $o1 = ' selected="selected"'; switch ($_POST['select']) : case 'po_zagolovku': $order = "&orderby=title&order=ASC&cat=$category"; $o1 = ' selected="selected"'; break; case 'snachala_novizne': $order = "&orderby=date&order=DESC&cat=$category"; $o2 = ' selected="selected"'; break; case 'snachala_starie': $order = "&orderby=date&order=ASC&cat=$category"; $o3 = ' selected="selected"'; break; case 'po_date_izmenenia': $order = "&orderby=modified&cat=$category"; $o4 = ' selected="selected"'; break; case 'po_polyu1': $order = "&meta_key=pole&orderby=meta_value&order=ASC&cat=$category"; $o5 = ' selected="selected"'; break; case 'po_polyu9': $order = "&meta_key=pole&orderby=meta_value&order=DESC&cat=$category"; $o6 = ' selected="selected"'; break; endswitch; print " <form method=\"post\" id=\"order\">Сортировать по: <select name=\"select\" onchange='this.form.submit()'> <option value=\"po_zagolovku\"$o1>заголовку</option> <option value=\"snachala_novizne\"$o2>дате (новые вперёд)</option> <option value=\"snachala_starie\"$o3>дате (старые вперёд)</option> <option value=\"po_date_izmenenia\"$o4>дате изменения</option> <option value=\"po_polyu1\"$o5>произвольному полю (по возрастанию)</option> <option value=\"po_polyu9\"$o6>произвольному полю (по убыванию)</option> </select> </form>"; query_posts($order); wp_reset_postdata(); /* Start the Loop */ ?> |
Рабочий пример:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php if ( is_category(array(201,202,203)) ) : $category = get_queried_object()->term_id; $paged = (get_query_var('paged')) ? get_query_var('paged'): 1; $order = "&meta_key=area&orderby=meta_value_num&order=ASC&cat=$category"; $o1 = ' selected="selected"'; switch ($_POST['select']) : case 'po_polyu1': $order = "&meta_key=area&orderby=meta_value_num&order=ASC&cat=$category"; $o1 = ' selected="selected"'; break; case 'po_polyu2': $order = "&meta_key=price&orderby=meta_value_num&order=ASC&cat=$category"; $o2 = ' selected="selected"'; break; endswitch; print " <form action=\"#order\" method=\"post\" id=\"order\">Сортировать по: <select name=\"select\" onchange='this.form.submit()'> <option value=\"po_polyu1\"$o1>площади</option> <option value=\"po_polyu2\"$o2>цене</option> </select> </form>"; query_posts($order); wp_reset_postdata(); else : $category = get_queried_object()->term_id; $order = "&orderby=menu_order&order=ASC&cat=$category"; query_posts($order); wp_reset_postdata(); endif; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <?php $order = "&meta_key=price-vosk-tara&orderby=meta_value_num&order=ASC&cat=31"; $order2 = "&meta_key=price-myod-vosk-tara&orderby=meta_value_num&order=ASC&cat=32"; $order3 = "&meta_key=price-podarok&orderby=meta_value_num&order=ASC&cat=33"; $o1 = ' selected="selected"'; switch ($_POST['select']) : case 'po_polyu1': $order = "&meta_key=price-vosk-tara&orderby=meta_value_num&order=ASC&cat=31"; $order2 = "&meta_key=price-myod-vosk-tara&orderby=meta_value_num&order=ASC&cat=32"; $order3 = "&meta_key=price-podarok&orderby=meta_value_num&order=ASC&cat=33"; $o1 = ' selected="selected"'; break; case 'po_polyu2': $order = "&meta_key=price-vosk-tara&orderby=meta_value_num&order=DESC&cat=31"; $order2 = "&meta_key=price-myod-vosk-tara&orderby=meta_value_num&order=DESC&cat=32"; $order3 = "&meta_key=price-podarok&orderby=meta_value_num&order=DESC&cat=33"; $o2 = ' selected="selected"'; break; endswitch; print " <form action=\"#lf-yakor\" method=\"post\" id=\"order\">Сортировать: <select name=\"select\" onchange='this.form.submit()'> <option value=\"po_polyu1\"$o1>по цене (сначала недорогие)</option> <option value=\"po_polyu2\"$o2>по цене (сначала дорогие)</option> </select> </form>"; ?> <div class="site-bloglist"> <h2><?php echo get_cat_name(31); ?></h2> <?php $query = new WP_Query($order); ?> <?php while( $query->have_posts() ) : $query->the_post(); ?> <?php get_template_part( 'content' ); ?> <?php endwhile; wp_reset_postdata(); ?> </div> <div class="site-bloglist"> <h2><?php echo get_cat_name(32); ?></h2> <?php $query = new WP_Query($order2); ?> <?php while( $query->have_posts() ) : $query->the_post(); ?> <?php get_template_part( 'content' ); ?> <?php endwhile; wp_reset_postdata(); ?> </div> <div class="site-bloglist"> <h2><?php echo get_cat_name(33); ?></h2> <?php $query = new WP_Query($order3); ?> <?php while( $query->have_posts() ) : $query->the_post(); ?> <?php get_template_part( 'content' ); ?> <?php endwhile; wp_reset_postdata(); ?> </div> |
1 2 | $queried_object = get_queried_object(); print_r( $queried_object ); |
Тип поля м.б. массив (например ссылки на записи), поэтому:
1 2 3 4 5 | $results=get_post_meta($post->ID, 'test', true); foreach ($results as $result) { echo '<a href="'.get_permalink($result).'" target="_blank">'.get_the_title($result).'</a>'; echo '<br>'; } |
движок:
1 2 | add_filter('pre_site_transient_update_core',create_function('$a', "return null;")); wp_clear_scheduled_hook('wp_version_check'); |
темы:
1 2 3 | remove_action('load-update-core.php','wp_update_themes'); add_filter('pre_site_transient_update_themes',create_function('$a', "return null;")); wp_clear_scheduled_hook('wp_update_themes'); |
плагины:
1 2 3 | remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); wp_clear_scheduled_hook( 'wp_update_plugins' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * reachGoal */ add_action( 'wp_footer', 'sendmail_wp_footer' ); function sendmail_wp_footer() { ?> <script type="text/javascript"> document.addEventListener( 'wpcf7mailsent', function( event ) { if ( '212' == event.detail.contactFormId ) { yaCounter12345678.reachGoal('zvonok'); } if ( '325' == event.detail.contactFormId ) { yaCounter12345678.reachGoal('quiz'); } }, false ); </script> <?php } ?> |
В footer.php после счетчика метрики:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <!-- Yandex.Metrika goals--> <script type="text/javascript"> jQuery( document ).ready( function ( $ ) { $( 'body' ).on( 'click', '.single_add_to_cart_button', function ( ) { yaCounter12345678.reachGoal('ADDTOCART'); } ).on( 'click', '.add_to_cart_button', function ( ) { yaCounter12345678.reachGoal('ADDTOCART'); } ); $( 'body' ).on( 'click', '#place_order', function ( ) { yaCounter12345678.reachGoal('PLACEORDER'); } ); } ); </script> <!-- /Yandex.Metrika goals --> |
1 | add_filter( 'widget_text', 'do_shortcode' ); |
Обратиться к элементам 'а' внутри меню и добавить класс:
1 2 3 4 5 6 7 8 | <script type="text/javascript"> window.onload=function(){ var menyua = document.getElementById('menu-glavnoe-menyu').getElementsByTagName("a"), x; for(x = 0; x < menyua.length; x++) { menyua[x].className = "_ps2id"; } } </script> |
Добавить класс элементу при скролле:
1 2 3 4 5 6 7 8 9 10 | ( function( $ ) { $(document).ready(function(){ $(window).scroll(function(){ if ( $(this).scrollTop() > 400 ) { $('#primary-navigation').addClass('lf-fix'); } else $('#primary-navigation').removeClass('lf-fix'); }); }); } )( jQuery ); |
или
1 2 3 4 5 | $(window).scroll(function(){ if ( $(this).scrollTop() > 400 ) { $('#effect').addClass('fadeInLeft'); } }) |
JQMIGRATE: Migrate is installed, version 1.4.1 = нормально, так и должно быть
Добавить jquery: (jquery вместо jquery-core отключает jqeury-migrate)
1 2 3 | wp_deregister_script('jquery-core'); wp_register_script('jquery-core', ("https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"), false, '1.12.2'); wp_enqueue_script('jquery'); |
Анимация сразу:
1 2 3 | <div class="fadeInDown animated"> test go </div> |
Анимация после скролла:
1 2 3 | <div class="LFfadeInLeft LFanimated"> test scroll </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <script> var x = document.querySelectorAll('.LFanimated'); for (var i = 0; i < x.length; i++) { x[i].style.visibility='hidden'; }; $(window).scroll(function() { $('.LFfadeInLeft').each(function(){ var imagePos = $(this).offset().top; var topOfWindow = $(window).scrollTop(); if (imagePos < topOfWindow+500) { $(this).addClass("fadeInLeft animated"); } }); $('.LFfadeInUp').each(function(){ var imagePos = $(this).offset().top; var topOfWindow = $(window).scrollTop(); if (imagePos < topOfWindow+500) { $(this).addClass("fadeInUp animated"); } }); $('.LFfadeInRight').each(function(){ var imagePos = $(this).offset().top; var topOfWindow = $(window).scrollTop(); if (imagePos < topOfWindow+500) { $(this).addClass("fadeInRight animated"); } }); }); </script> |
wp-admin/load-styles.php
1 2 3 | error_reporting(0); error_reporting( E_ALL | E_STRICT ); |
...and then simply refresh your WordPress admin screen a few times. You should see the WordPress admin CSS styles come back to normal.
A non-WordPress core hack that might work for some is to add the following code to you wp-config.php
1 2 | define( ‘CONCATENATE_SCRIPTS’, false ); define( ‘SCRIPT_DEBUG’, true ); |