-
AuthorPosts
-
August 14, 2016 at 11:11 am #672349
Hi, I have a couple of post categories (news and video) and I would like to change the text ‘Read More’ to ‘Watch the video’ only for those posts that belong to that category. Can it be done with a function without touching core files? Thank you.
August 18, 2016 at 2:31 am #673964Hey Alberto,
Thank you for using Enfold
What is the actual slug of the “video” category? Please add something like this in the functions.php file:
// custom script add_action( 'wp_footer', 'ava_custom_script' ); function ava_custom_script() { ?> <script type="text/javascript"> (function($) { function b() { var video = $('body').hasClass('category-video'); if(!video) return; $('.more-link').each(function() { $(this).empty(); $(this).text('Watch the video'); }); } b(); })(jQuery); </script> <?php }
Best regards,
IsmaelAugust 18, 2016 at 1:05 pm #674158My videos are on Vimeo and each shortcode is inside a code block in a post which has the category slug ‘video’. Then I have a gallery/video page which contains the avia article module filtered by the category video so it shows the last 3 article by that category. At the moment there’s no class associated to the videos, but if needed I can add it in the code block. The function should change the text “read more” of the button to ‘watch the video’ only for those articles belonging to the video cat. Then, since the website will be in 3 languages, I guess the easiest way will be to add the line ‘watch the video’ in a .pot file (if it doesn’t exist already) and have it translated accordingly.
I tried the above function changing ‘category-video’ to ‘video’ (the cat slug) but nothing happens.
I’m using a child theme of the Gym Demo. Thank you.August 19, 2016 at 8:40 am #674588Ok, I solved the problem with this function:
function ava_custom_script() { ?> <script type="text/javascript"> (function($) { function b() { var video = $('article').hasClass('category-video') || $('article').hasClass('category-video-en'); if(!video) return; $('.more-link').each(function() { $(this).empty(); $(this).text('Watch the video'); }); } b(); })(jQuery); </script> <?php } add_action( 'wp_footer', 'ava_custom_script' );
Thank you for putting me on the right track!
- This reply was modified 8 years, 3 months ago by alby54.
August 20, 2016 at 7:24 am #674950 -
AuthorPosts
- You must be logged in to reply to this topic.