This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Adding elements to the Post Slider

  • Creator
    Topic
  • #9964
    Wendell Harness
    Participant

    In the Post Slider (via Builder), I would like to add a Facebook Like button next to the read more button. But I’m having a hard time finding where that happens so I can override the function.

    Just to give you an idea of where I’m going with this, please take a look at http://justgoodnews.biz/ — that’s not my site, but check out the READ, SHARE and FB like buttons below the content. This is what I’m trying to do.

    Can you give me some insight as to where to look and/or the preferred method? Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #9972
    Jason Bobich
    Keymaster

    You could possibly just filter on whatever HTML markup you need to the description of each slide. Every time a slider is displayed, the first thing that happens is that a filter “themeblvd_standard_slides” is applied to the array that makes up the entire slider of slides.

    So for example, here’s a sort of setup:

    function my_standard_slides( $slides, $slider, $settings ) {
    	
    	// ID of Slider: $slider 
    	// Settings of current slider: $settings
    	// An array of all slides: $slides
    	
    	foreach ( $slides as $id => $slide ) {
    		// See what's in each $slide you can use
    		// print_r($slide);
    
    		// For example, where the description is
    		$slides[$id]['elements']['description'] .= 'facebook like button code here';
    	}
    
    	return $slides;
    }
    add_filter( 'themeblvd_standard_slides', 'my_standard_slides', 10, 3 );
    #9994
    Darryl Schmidt
    Participant

    I’ve tried playing around with this also and am not getting anything to show up in the slides’ description area. But this will be my first-ever filter and I’m still learning PHP. 🙂

    So I know I’m probably missing something since I don’t really know what I’m doing. I basically just copied your code and unremarked a couple of lines, but there must be something else I’m needing to do?

    function my_standard_slides( $slides, $slider, $settings ) {
    	foreach ( $slides as $slide ) {
    		// See what's in each $slide you can use
    		print_r($slide);
    		// For example, where the description is
    		$slide['elements']['description'] .= 'facebook like button code here';
    	}
    	return $slides;
    }
    add_filter( 'themeblvd_standard_slides'. 'my_standard_slides', 10, 3 );

    Also, having the Like button in there means that I’ll need to pull the post permalink that each slide is referencing. And for what it’s worth, it’s the Post Slider in the Builder area that I’m dealing with here, not the Post List or Post Grid sliders.

    #9997
    Jason Bobich
    Keymaster

    Well, first off, I made a pretty obvious typo above (which I’ve now fixed), and that is making it so the code essentially does nothing. I put a period instead of a comma. Where the filter is added should be this:

    add_filter( 'themeblvd_standard_slides', 'my_standard_slides', 10, 3 );

    And then here’s a better example of how you’d specifically add to the description using that permalink.

    function my_standard_slides( $slides, $slider, $settings ) {
    	foreach ( $slides as $id => $slide ) {
    
    		// If the image links are setup to link to the
    		// posts, here's how you'd grab that permalink.
    		$permalink = $slide['elements']['image_link']['url'];
    
    		// Add to the description
    		$slides[$id]['elements']['description'] .= '<a href="http://twitter.com/home?status='.$permalink.'">Share</a>';
    
    	}
    	return $slides;
    }
    add_filter( 'themeblvd_standard_slides', 'my_standard_slides', 10, 3 );
    #10003
    Wendell Harness
    Participant

    Once again, Jason to the rescue. Thank you! Here’s my final code, in case it helps someone else:

    function my_standard_slides( $slides, $slider, $settings ) {
    	foreach ( $slides as $id => $slide ) {
    
    		// If the image links are setup to link to the
    		// posts, here's how you'd grab that permalink.
    		$permalink = urlencode($slide['elements']['image_link']['url']);
    
    		// Add to the description
    		$slides[$id]['elements']['description'] .= '<div class="fb-like-post"><iframe src="http://www.facebook.com/plugins/like.php?href='.$permalink.'&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=true&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21&amp;appId=1234567890" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></div>';
    	}
    	return $slides;
    }
    add_filter( 'themeblvd_standard_slides', 'my_standard_slides', 10, 3 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.