• Resolved completocreate

    (@completocreate)


    first, congratulations on the plugin.

    i am trying to get the members name, i tried that.

    /**
     * Parses custom content tags in WordPress Popular Posts.
     *
     * @param  string  $html    The HTML markup from the plugin.
     * @param  integer $post_id The post/page ID.
     * @return string
     */
    function wpp_parse_tags_in_popular_posts($html, $post_id){
    
        // Replace custom content tag {member_name} with
        // the stock member as generated by WordPress
        if ( false !== strpos($html, '{member_name}') ) {
            // Get member
            $member_name = get_member_name($post_id');
    
            if ( $member_name ) {
                // Replace {member_name} with the actual member
                $html = str_replace('{member_name}', $member_name, $html);
            }
        }
    
        return $html;
    
    }
    add_filter("wpp_parse_custom_content_tags", "wpp_parse_tags_in_popular_posts", 10, 2);
    
    $args = array(
        'wpp_start' => '<div class="slider">',
        'wpp_end' => '</div>',
        'post_html' => '<div class="item">{member_name}</div>',
        'thumbnail_width' => 500,
        'thumbnail_height' => 'auto',
        'limit' => 100,
        'range' => 'last24hours',
        'post_type' => 'post'
    );
    
    wpp_get_mostpopular( $args );
    

    Full code for a member

                      $songId = get_the_ID();
                      $memberId = get_post_meta($songId, '_member_name', true);
                      if($memberId != ""){
                        $get_member_name = new WP_Query( array( 
                            'post_type' => 'member',
                            'posts_per_page' => -1,
                            'p' => $memberId,
                        ));
                        if( $get_member_name->have_posts() ) : 
                            while( $get_member_name->have_posts() ) : $get_member_name->the_post(); 
                            $member_name = get_the_title();
                            $member_link = get_permalink();
                        endwhile;
                        endif;
                      ?>
    
    <a href="<?php echo esc_attr($member_link); ?>"><?php echo esc_attr($member_name); ?></a>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Member Name’ is closed to new replies.