Add link to post
-
Hey
I am using this and I want to add link to whole grid with respective post link when it displays the posts in grid.
How can I add Link?
https://pasteboard.co/f1ci11TW79W3.png
Thanks
Mansi
-
Hi! You should use custom layout to create your own post card layout. Use a filter for this, for example:
add_filter(‘ymc_filter_custom_layout_545_1’, ‘my_custom_filter_layout’, 10, 6);
Refer to the plugin documentation – https://github.com/YMC-22/smart-filterHi
Thanks for the reply. For testing I have used your code and replaced filterID and LayoutID. But it gives error. Not showing whole error. Whole site gets down. For refernce I have added code. could u check and let me know what mistake is there.function my_custom_post_layout($layout, $post_id, $filter_id, $increment_post, $arrOptions) {
$layout .= ‘<h2>’.get_the_title($post_id).'</h2>’;
$layout .= ‘<p>’.wp_trim_words(get_the_content($post_id), 30).'</p>’;
$layout .= ‘<a href=”‘.get_the_permalink($post_id).'”>Read More</a>’;
return $layout;
}
add_filter(‘ymc_post_custom_layout_4488_1’, ‘my_custom_post_layout’, 10, 5);
Please send a link to the page of your site where you use the plugin. It’s very difficult to determine what could be wrong…
We have checked your code and would like to report that filtering is working correctly. Our plugin does not generate any errors and posts are filtered correctly according to the specified parameters (see screenshot – https://prnt.sc/JxLPsvV1UC0Z).
Here we see the appearance of errors in the scripts of your site, which are most likely caused by other installed plugins or perhaps. custom scripts. In addition, clear the cache on your server since the site works with WPEngine, and this is a cached server.No actually you misunderstood. I am not talking about filtering. I want to add custom layout so that I can give link to whole grid with respective post link. But the code I have given isn’t working giving error. Need to add image as well but this simple code is not working.
Let me know you understand my question or not.
Thanks
You are already using a custom layout here to display grid of posts and filtering works correctly. To add an image to a post card, use the standard WordPress functions for displaying an image. Therefore, the example code that was given above works correctly… or perhaps we don’t fully understand your issue. What error does this code display? From our side we see nothing…
-
This reply was modified 2 years ago by
YMC.
Can you check now why it is showing like that?
remove the dots when assigning to the $layout variable – https://prnt.sc/b6g3JSdCzAur
it should be like this:
function my_custom_post_layout($layout, $post_id, $filter_id, $increment_post, $arrOptions) {$layout = ‘<h2>’.get_the_title($post_id).’</h2>’; $layout .= ‘<p>’.wp_trim_words(get_the_content($post_id), 30).'</p>’; $layout .= ‘<a href=”‘.get_the_permalink($post_id).’”>Read More</a>’; return $layout;}
-
This reply was modified 2 years ago by
The topic ‘Add link to post’ is closed to new replies.