WordPress.org

Ready to get started?Download WordPress

Forums

WP Rotator
Examples of function markup (2 posts)

  1. David Radovanovic
    Member
    Posted 2 years ago #

    Anyway to get some examples of the added functions markups, i.e. I'd like to add link to relative post not by image, but by post title. Thanks!

    http://wordpress.org/extend/plugins/wp-rotator/

  2. David Radovanovic
    Member
    Posted 2 years ago #

    I added the click-through link to the titles via adding the code below to my functions.php file:

    function custom_rotator_featured_cell_markup($result) {
        global $post, $animate_style, $first;
        $clickthrough_url = esc_attr(get_post_meta($post->ID, 'wp_rotator_url', true));
        $show_info = esc_attr(get_post_meta($post->ID, 'wp_rotator_show_info', true));
        /* Backwards compatible with old version, where we didn't prefix the field */
        if (empty($clickthrough_url)) { $clickthrough_url = esc_attr(get_post_meta($post->ID,'url',true)); }
        if (empty($show_info)) { $show_info = esc_attr(get_post_meta($post->ID,'show_info',true)); }
        /* */
        if (!isset($clickthrough_url)) {
          $clickthrough_url = get_permalink($post->ID);
        }
        $result .= '<li class="featured-cell"';
            if ($animate_style == 'fade') {
              if ($first) {
                $first = false;
              }
              else {
                $result .= 'style="display:none;"';
              }
            }
        $result .= '>';
        $result .= '<a href="' . $clickthrough_url . '">';
        $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'wp_rotator' );
        global $bsd_pane_height, $bsd_pane_width;
    if ($image[1] == $bsd_pane_height && $image[2] == $bsd_pane_width)
    $result .= get_the_post_thumbnail( $post->ID, 'wp_rotator' );
    else $result .= ' <img width="' . $bsd_pane_width . '" height="' . $bsd_pane_height . '" src="' . $image[0] . '" />';
    
        $result .= '</a>';
    
        if ($show_info == true):
          $result .= ' <div class="info">';
          $result .= '<a href="' . $clickthrough_url . '"> <!-- added link to title -->';
          $result .= ' <h1>' . get_the_title() .'</h1>';
    
          $result .= '</a><!-- closed link to title  --> ';
    
          if (get_the_excerpt()) $result .= ' <p>' . get_the_excerpt() . '</p>';
          $result .= ' </div>';
        endif;
    
        $result .= '</li><!-- featured-cell -->';
        return $result;
    }
    remove_filter('wp_rotator_featured_cell_markup','wp_rotator_featured_cell_markup');
    add_filter('wp_rotator_featured_cell_markup','custom_rotator_featured_cell_markup');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags