Wsparcie » Wtyczki » Słowo "Komentarz"

  • Rozwiązano Orri

    (@orri)


    Cześć.
    Posiadam motyw Twenty Twelve no i chciałbym poprawić odmianę słowa Komentarz na stronie głównej i w komentarzach. Przeglądałem ten temat: http://pl.forums.wordpress.org/topic/prawidlowa-wersja-slowa-komentarze
    oraz ten w linku tam podany i zawsze wyskakiwał mi błąd. Proszę o pomoc. Poniżej przedstawiam kod pliku comments.php:

    <?php
    /**
     * The template for displaying Comments.
     *
     * The area of the page that contains both current comments
     * and the comment form. The actual display of comments is
     * handled by a callback to twentytwelve_comment() which is
     * located in the functions.php file.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    /*
     * If the current post is protected by a password and
     * the visitor has not yet entered the password we will
     * return early without loading the comments.
     */
    if ( post_password_required() )
    	return;
    ?>
    
    <div id="comments" class="comments-area">
    
    	<?php // You can start editing here -- including this comment! ?>
    
    <?php if ( have_comments() ) : ?>
    		<h2 class="comments-title">
    			<?php
    				printf( _n( '1 Komentarz artykułu: &ldquo;%2$s&rdquo;', '%1$s komentarzy artykułu: &ldquo;%2$s&rdquo;', get_comments_number(), 'twentytwelve' ),
    					number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
    			?>
    		</h2>
    
    		<ol class="commentlist">
    <?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) ); ?>
    
    		</ol><!-- .commentlist -->
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    		<nav id="comment-nav-below" class="navigation" role="navigation">
    			<h1 class="assistive-text section-heading"><?php _e( 'Comment navigation', 'twentytwelve' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'twentytwelve' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'twentytwelve' ) ); ?></div>
    		</nav>
    		<?php endif; // check for comment navigation ?>
    
    		<?php
    		/* If there are no comments and comments are closed, let's leave a note.
    		 * But we only want the note on posts and pages that had comments in the first place.
    		 */
    		if ( ! comments_open() && get_comments_number() ) : ?>
    		<p class="nocomments"><?php _e( 'Comments are closed.' , 'twentytwelve' ); ?></p>
    		<?php endif; ?>
    
    	<?php endif; // have_comments() ?>
    
    	<?php comment_form(); ?>
    
    </div><!-- #comments .comments-area -->
Viewing 6 replies - 1 through 6 (of 6 total)
  • <?php
    function odmiana($in,$lp,$lm1,$lm2) {
     if ($in==1) return $in.' '.$lp;
     elseif (($in%10>1) && ($in%10<5) && !(($in%100>=10) && ($in%100<=21))) return $in.' '.$lm1;
    return $in.' '.$lm2;
    };
    
    echo odmiana(get_comments_number(),'Komentarz','Komentarze','Komentarzy');
    ?>
    Thread Starter Orri

    (@orri)

    Pomogło dzięki. Mam jeszcze jedną prośbę, bo tamto wyżej zmienilo mi odmianę po wejściu w artykuł, a chciałbym także żeby na stronie głównej, jak mam pod tytułem ilość komentarzy także zmienili.
    Daje kawałek kodu z content.php i proszę o pomoc z kodem i gdzie mam go wkleić.

    <?php if ( comments_open() ) : ?>
    				<div class="comments-link">
    					<?php comments_popup_link( '<span class="leave-reply">' . __( 'Komentuj', 'twentytwelve' ) . '</span>', __( '1 Komentarz', 'twentytwelve' ), __( '% Komentarzy', 'twentytwelve' ) ); ?>
    				</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>

    Tak na szybko można sobie wykorzystać zmodyfikowaną funkcję comments_popup_link

    do pliku functions.php wrzucasz wcześniej podaną funkcję odmiana i taką:

    function my_comments_popup_link($css_class = '', $none = false ) {
    	global $wpcommentspopupfile, $wpcommentsjavascript;
    	$id = get_the_ID();
    	if ( false === $none ) $none = __( 'Comments Off' );
    	$number = get_comments_number( $id );
    	if ( 0 == $number && !comments_open() && !pings_open() ) {
    		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
    		return;
    	}
    	if ( post_password_required() ) { echo __('Enter your password to view comments.');	return;	}
    	echo '<a href="';
    	if ( $wpcommentsjavascript ) {
    		if ( empty( $wpcommentspopupfile ) ) $home = home_url();
    		else $home = get_option('siteurl');
    		echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
    		echo '" onclick="wpopen(this.href); return false"';
    	} else { // if comments_popup_script() is not in the template, display simple comment link
    		if ( 0 == $number )	echo get_permalink() . '#respond';
    		else comments_link(); echo '"';
    	}
    	if ( !empty( $css_class ) ) { echo ' class="'.$css_class.'" ';	}
    	$title = the_title_attribute( array('echo' => 0 ) );
    	echo apply_filters( 'comments_popup_link_attributes', '' );
    	echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
    	echo odmiana($number,'Komentarz','Komentarze','Komentarzy');
    	echo '</a>';
    }

    potem w content.php dajesz tak:

    <?php if ( comments_open() ) : ?>
    				<div class="comments-link">
    					<?php my_comments_popup_link( 'leave-reply'); ?>
    				</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>

    ….chociaż można by pewnie na kilka innych sposobów to zrobić.

    Thread Starter Orri

    (@orri)

    Wklejam w functions.php odmiane i podany kod i mam blad:
    Warning: Cannot modify header information - headers already sent by (output started at /home/orri/public_html/wp-content/themes/twentytwelve/functions.php:674) in /home/orri/public_html/wp-includes/pluggable.php on line 876 ;/

    1. A czy zapisywałeś plik z kodowaniem UTF-8 bez BOM ?
    2. w jaki sposób wstawiłeś ….mam nadzieję, że wewnątrz znaczników <?php i ?> a nie poza nimi

    Thread Starter Orri

    (@orri)

    Rozwiązałem problem. Niechcący usunąłem część poprzedniego kodu, teraz wszystko dobrze.
    Lecz mam jeszcze jeden problem ponieważ w górnym lewym rogu mam: ” 0 Komentarzy ” Gdzie to w kodzie usunąć?

    2. Po wejściu we wpis mam:
    Fatal error: Cannot redeclare odmiana() (previously declared in /home/orri/public_html/wp-content/themes/twentytwelve/functions.php:674) in /home/orri/public_html/wp-content/themes/twentytwelve/comments.php on line 32

Viewing 6 replies - 1 through 6 (of 6 total)
  • Temat ‘Słowo "Komentarz"’ jest zamknięty na nowe odpowiedzi.