YMC-22 / smart-filter

YMC Smart Filter, allows to solve a variety of tasks for displaying posts on site pages. For advanced developers, there is an opportunity to independently develop layouts for filters and post cards, which makes the plugin universal.
14 stars 6 forks source link

tried to change the color and text of post button "Read More", but not sure how to use the provided samples. #7

Closed johocen168 closed 10 months ago

johocen168 commented 10 months ago

Thanks for the nice plugin, it is easy to use and exactly what we need. but it's a pitty that can not change the color and text of post button easily.

copied the code you provided in "Example Custom Post Layout" but it seems every post has a different id number, please see the screenshot and help me with the code, thanks shot_231230_231412

function my_custom_post_layout($layout, $post_id, $filter_id, $increment_post, $arrOptions) {
$layout = '

'.get_the_title($post_id).'

'; $layout .= '

'.wp_trim_words(get_the_content($post_id), 30).'

'; $layout .= 'Read More'; // $layout .= 'Open Popup';
return $layout; } add_filter('ymc_post_custom_layout_545_1', 'my_custom_post_layout', 10, 5);

YMC-22 commented 10 months ago

Hello! You will need to use a filter ID called 51502-1 Thus the name of the filter will be as follows: add_filter('ymc_post_custom_layout_51502_1', 'my_custom_post_layout', 10, 5); We hope this helps you. Clipboard01

johocen168 commented 10 months ago

Sorry for late response, I was away from home.

I was confused, the short code is [ymc_filter id='51502']

I used the plugin "Snippet" to add the code as following, but didn't work, how can I make it right?

function my_custom_post_layout($layout, $post_id=51446, $filter_id=51502_1, $increment_post, $arrOptions) { $layout = '<h2>'.get_the_title($post_id=51446).'</h2>'; $layout .= '<p>'.wp_trim_words(get_the_content($post_id=51446), 30).'</p>'; $layout .= '<a href="'.get_the_permalink($post_id=51446).'">Read333More</a>'; // $layout .= '<a class="'.esc_attr($arrOptions['class_popup']).'" data-postid="'.esc_attr($post_id).'" href="#">Open Popup</a>'; return $layout; } add_filter('ymc_post_custom_layout_51502_1', 'my_custom_post_layout', 10, 5);