Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




comments_popup_link [ WordPress Function ]

comments_popup_link ( $zero = false, $one = false, $more = false, $css_class = '', $none = false )
Parameters:
  • (string) $zero The string to display when no comments
  • (string) $one The string to display when only one comment is available
  • (string) $more The string to display when there are more than one comment
  • (string) $css_class The CSS class to use for comments
  • (string) $none The string to display when comments have been turned off
Uses:
  • $wpcommentspopupfile
  • $wpcommentsjavascript
  • $post
Returns:
  • (null) Returns null on single posts and pages.
Defined at:



Displays the link to the comments popup window for the current post ID.

Is not meant to be displayed on single posts and pages. Should be used on the lists of posts

Source


<?php
function comments_popup_link$zero false$one false$more false$css_class ''$none false ) {
    global 
$wpcommentspopupfile$wpcommentsjavascript;

    
$id get_the_ID();

    if ( 
false === $zero $zero __'No Comments' );
    if ( 
false === $one $one __'1 Comment' );
    if ( 
false === $more $more __'% Comments' );
    if ( 
false === $none $none __'Comments Off' );

    
$number get_comments_number$id );

    if ( 
== $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 ( == $number )
            echo 
get_permalink() . '#respond';
        else
            
comments_link();
        echo 
'"';
    }

    if ( !empty( 
$css_class ) ) {
        echo 
' class="'.$css_class.'" ';
    }
    
$title the_title_attribute( array('echo' => ) );

    echo 
apply_filters'comments_popup_link_attributes''' );

    echo 
' title="' esc_attrsprintf__('Comment on %s'), $title ) ) . '">';
    
comments_number$zero$one$more );
    echo 
'</a>';
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics