Вопросы по допиливанию шаблона и ЦМС

(Ответов: 13, Просмотров: 3548)
Страница 2 из 2 Первая 12
  1. Опытный Аватар для nbsp
    • Регистрация: 10.11.2011
    • Сообщений: 423
    • Репутация: 50
    hronny, переменная,которая отвечает за главную страницу сайта это is_front_page().
    Чтобы реализовать большинство задач в Ваших вопросах она подойдет. смотрите в сторону условных операторов php и на это условие.
    С Уважением, Андрей.
    • 0
  2. Новичок
    • Регистрация: 28.01.2013
    • Сообщений: 2
    • Репутация: 2
    hronny,
    Закрываем категории в сайдбаре.
    идем сюда:
    site.ru\wp-includes\nav-menu-template.php
    ищем этот код:
    PHP код:
        function start_el( &$output$item$depth 0$args = array(), $id ) {
            
    $indent = ( $depth ) ? str_repeat"\t"$depth ) : '';

            
    $class_names $value '';

            
    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
            
    $classes[] = 'menu-item-' $item->ID;

            
    $class_names join' 'apply_filters'nav_menu_css_class'array_filter$classes ), $item$args ) );
            
    $class_names $class_names ' class="' esc_attr$class_names ) . '"' '';

            
    $id apply_filters'nav_menu_item_id''menu-item-'$item->ID$item$args );
            
    $id $id ' id="' esc_attr$id ) . '"' '';

            
    $output .= $indent '<li' $id $value $class_names .'>';

            
    $attributes  = ! empty( $item->attr_title ) ? ' title="'  esc_attr$item->attr_title ) .'"' '';
            
    $attributes .= ! empty( $item->target )     ? ' target="' esc_attr$item->target     ) .'"' '';
            
    $attributes .= ! empty( $item->xfn )        ? ' rel="'    esc_attr$item->xfn        ) .'"' '';
            
    $attributes .= ! empty( $item->url )        ? ' href="'   esc_attr$item->url        ) .'"' '';

            
    $item_output $args->before;
            
    $item_output .= '<a'$attributes .'>';
            
    $item_output .= $args->link_before apply_filters'the_title'$item->title$item->ID ) . $args->link_after;
            
    $item_output .= '</a>';
            
    $item_output .= $args->after;

            
    $output .= apply_filters'walker_nav_menu_start_el'$item_output$item$depth$args );
        } 
    меняем на этот:

    PHP код:
    function start_el( &$output$item$depth 0$args = array(), $id ) {
            
    $indent = ( $depth ) ? str_repeat"\t"$depth ) : '';

            
    $class_names $value '';

            
    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
            
    $classes[] = 'menu-item-' $item->ID;

            
    $class_names join' 'apply_filters'nav_menu_css_class'array_filter$classes ), $item$args ) );
            
    $class_names $class_names ' class="' esc_attr$class_names ) . '"' '';

            
    $id apply_filters'nav_menu_item_id''menu-item-'$item->ID$item$args );
            
    $id $id ' id="' esc_attr$id ) . '"' '';

            
    $output .= $indent '<li' $id $value $class_names .'>';

            
    $attributes  = ! empty( $item->attr_title ) ? ' title="'  esc_attr$item->attr_title ) .'"' '';
            
    $attributes .= ! empty( $item->target )     ? ' target="' esc_attr$item->target     ) .'"' '';
            
    $attributes .= ! empty( $item->xfn )        ? ' rel="'    esc_attr$item->xfn        ) .'"' '';
            
    $attributes .= ! empty( $item->url )        ? ' href="'   esc_attr$item->url        ) .'"' '';

            
    $item_output $args->before;
            
    $item_output .= '<noindex><a rel="nofollow" '$attributes .'>';
            
    $item_output .= $args->link_before apply_filters'the_title'$item->title$item->ID ) . $args->link_after;
            
    $item_output .= '</a></noindex>';
            
    $item_output .= $args->after;

            
    $output .= apply_filters'walker_nav_menu_start_el'$item_output$item$depth$args );
        } 
    У вас под каждым постом, в развернутом виде и свернутом, есть категории, вот их лучше оставить открытыми, а то что выводится на каждой странице в сайдбаре с одними и теми же категориями это плохо, и их следует закрыть. Как и зачем, думаю понятно.

    ---------- Сообщение добавлено 09:06 ---------- Предыдущее 08:21 ----------

    hronny,
    Как закрыть главное меню (верхнее) от индексации.
    идем сюда:
    site.ru\wp-includes\post-template.php
    ищем код
    PHP код:
    function start_el( &$output$page$depth$args$current_page ) {
            if ( 
    $depth )
                
    $indent str_repeat("\t"$depth);
            else
                
    $indent '';

            
    extract($argsEXTR_SKIP);
            
    $css_class = array('page_item''page-item-'.$page->ID);
            if ( !empty(
    $current_page) ) {
                
    $_current_page get_post$current_page );
                if ( 
    in_array$page->ID$_current_page->ancestors ) )
                    
    $css_class[] = 'current_page_ancestor';
                if ( 
    $page->ID == $current_page )
                    
    $css_class[] = 'current_page_item';
                elseif ( 
    $_current_page && $page->ID == $_current_page->post_parent )
                    
    $css_class[] = 'current_page_parent';
            } elseif ( 
    $page->ID == get_option('page_for_posts') ) {
                
    $css_class[] = 'current_page_parent';
            }

            
    $css_class implode' 'apply_filters'page_css_class'$css_class$page$depth$args$current_page ) );

            
    $output .= $indent '<li class="' $css_class '"><a href="' get_permalink($page->ID) . '">' $link_before apply_filters'the_title'$page->post_title$page->ID ) . $link_after '</a>';

            if ( !empty(
    $show_date) ) {
                if ( 
    'modified' == $show_date )
                    
    $time $page->post_modified;
                else
                    
    $time $page->post_date;

                
    $output .= " " mysql2date($date_format$time);
            }
        } 
    меняем на:
    PHP код:
    function start_el( &$output$page$depth$args$current_page ) {
            if ( 
    $depth )
                
    $indent str_repeat("\t"$depth);
            else
                
    $indent '';

            
    extract($argsEXTR_SKIP);
            
    $css_class = array('page_item''page-item-'.$page->ID);
            if ( !empty(
    $current_page) ) {
                
    $_current_page get_post$current_page );
                if ( 
    in_array$page->ID$_current_page->ancestors ) )
                    
    $css_class[] = 'current_page_ancestor';
                if ( 
    $page->ID == $current_page )
                    
    $css_class[] = 'current_page_item';
                elseif ( 
    $_current_page && $page->ID == $_current_page->post_parent )
                    
    $css_class[] = 'current_page_parent';
            } elseif ( 
    $page->ID == get_option('page_for_posts') ) {
                
    $css_class[] = 'current_page_parent';
            }

            
    $css_class implode' 'apply_filters'page_css_class'$css_class$page$depth$args$current_page ) );

            
    $output .= $indent '<li class="' $css_class '"><noindex><a rel="nofollow" href="' get_permalink($page->ID) . '">' $link_before apply_filters'the_title'$page->post_title$page->ID ) . $link_after '</a></noindex>';

            if ( !empty(
    $show_date) ) {
                if ( 
    'modified' == $show_date )
                    
    $time $page->post_modified;
                else
                    
    $time $page->post_date;

                
    $output .= " " mysql2date($date_format$time);
            }
        } 
    Закроется все меню, но надо открыть для индексации карту сайта!
    для этого идем в виджеты либо в футер.пхп и вставляем ссылку на карту сайта.
    PHP код:
    <a href="http://site.ru/karta-sajta/">Карта сайта</a
    по поводу комментариев надо думать, заморочусь на неделе.
    • 1

    Спасибо сказали:

    hronny(30.01.2013),
  3. Гуру Аватар для hronny
    • Регистрация: 07.06.2011
    • Сообщений: 1,090
    • Репутация: 416
    • Webmoney BL: ?
    О комментариях. Удалить поля можно в файле site.ru\wp-includes\comment-template.php

    Ищем блок:
    PHP код:
    $fields =  array(
            
    'author' => '<p class="comment-form-author">' '<label for="author">' __'Name' ) . ( $req ' <span class="required">*</span>' '' ) . '</label> ' .
                        
    '<input id="author" name="author" type="text" value="' esc_attr$commenter['comment_author'] ) . '" size="30"' $aria_req ' /></p>',
            
    'email'  => '<p class="comment-form-email"><label for="email">' __'Email' ) . ( $req ' <span class="required">*</span>' '' ) . '</label> ' .
                        
    '<input id="email" name="email" type="text" value="' esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' $aria_req ' /></p>',
            
    'url'    => '<p class="comment-form-url"><label for="url">' __'Website' ) . '</label>' .
                        
    '<input id="url" name="url" type="text" value="' esc_attr$commenter['comment_author_url'] ) . '" size="30" /></p>',
        ); 
    И удаляем все, что относится к 'url'. Поле "Сайт" удалили. С полем "email" все гораздо сложнее. Само поле удалить легко, но вот условие "для комментирования нужны логин и мыло" все равно выскакивает. Нужно смотреть в сторону функции
    Код:
    require_name_email
    Я так понимаю, что идет запрос к базе данных. В одной таблице содержатся и имя, и мыло. Так вот, для полного избавления от поля электронной почты нужно переписать функцию запроса к базе данных. Функция должна запрашивать только имя. А вот как это сделать - я не знаю.
    • 0
  4. Гуру Аватар для hronny
    • Регистрация: 07.06.2011
    • Сообщений: 1,090
    • Репутация: 416
    • Webmoney BL: ?
    По поводу обязательности заполнения полей. Это дело легко отключается в настройках ВП: Параметры -- обсуждение -- Автор комментария должен указать имя и e-mail. Снимаем галочку, удаляем ненужные поля. А со спамом акисмет справляется:) (хотя по личным наблюдениям, количество спама сократилось в разы после удаления поля"Сайт")
    • 0
Страница 2 из 2 Первая 12

Похожие темы

Темы Раздел Ответов Последний пост
Миграция шаблона
Joomla 0 14.06.2012 14:37
Правка шаблона
Joomla 6 06.06.2012 02:36
Перевод шаблона
WordPress 4 22.04.2012 02:11
По поводу шаблона на WP
Web дизайн 4 18.03.2012 02:55
Макет шаблона
Web программирование 4 23.10.2011 02:47

У кого попросить инвайт?

Вы можете попросить инвайт у любого модератора:

Информеры