• Resolved brad1004

    (@brad1004)


    Hi there

    I have had another go getting custom fields to work in this this lovely Carousel.

    I wanted to add an event date field and move the post title above the featured image (I found disabling the featured image in the settings and adding a new image from a custom field worked)

    This is the code I ended up with which is working – but this is my first attempt at filters so I presume it is a bit of a mess….

    function my_wpc_item_description( $description, $params ) {
    
    //get the startdate without the time
    	$startdate = eo_get_the_start();
    	$post_content = get_the_content();
    	$the_image = get_field('my_photo');
    	$data_src = '<img src="' . $the_image . '" />';
    
    	$description = '
    					<div class="wp-posts-carousel-desc">
    					    <div class="my-image"> ' . $data_src . ' . </div>
    						<div class="the-date">' . $startdate . '</div>
    						<div class="main-content"> ' . $post_content . '</div>
    
    					</div>';
    
    	return $description;
    }
    add_filter('wpc_item_description', 'my_wpc_item_description', 1, 2);

    Any guidance on improving this code would be appreciated
    Thank You

    https://www.ads-software.com/plugins/wp-posts-carousel/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author teastudio.pl

    (@teastudiopl)

    I think it’s ok.
    Instead of: <div class=”the-date”> and <div class=”main-content”> you can use span

    Thread Starter brad1004

    (@brad1004)

    Thank you very much for your reply and help.

    Greatly appreciated.

    I am still unsure of the two numbers that are displayed at the end of the filter, namely 1,2

    add_filter('wpc_item_description', 'my_wpc_item_description', 1, 2);

    I have read the first number is the priority – I gather this will effect where the included fields appear? I am not sure where the second number – in this case 2 – comes from and when you should change it..

    I have read it is accepted args – does that mean $description, $params ?

    If anyone can offer some insight into this I would be most greatful

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field check -please’ is closed to new replies.