
Tagged: category, custom url, External Link
-
AuthorPosts
-
October 25, 2018 at 3:53 pm #1026376
Is there a way to have a category’s thumbnail and text be an external link (vs linking to the specific category page of the home website)
EG: I’d like to have a Art Prints category that when clicked goes to an external url NOT an Art Prints page of my website
October 26, 2018 at 2:25 pm #1026799Hey ATX,
Could you please attach a mockup of what you’re trying to achieve?
Best regards,
VictoriaOctober 27, 2018 at 9:17 pm #1027198Hi Victoria, I couldn’t see where/how to attach an image to this message, but if you go to the URL of each page, you’ll see what I mean (see links below).
I have 2 different WordPress store installations on my domain, ‘Secret’ and ‘Shop’. Is there a way to have a category thumbnail/text that links to an external link? EG: I’d like to display a T Shirts category thumbnail on the main ‘Secret’ storefront but have it link to the T Shirts page of the ‘Shop’ installation/section of website (instead of linking to the T Shirts page of the ‘Secret’ installation/section)
Also, I created a T Shirts category for ‘Secret’ but it’s not appearing – I assume because there are no products listed under that category for that section of the website?
SECRET installation: https://www.beastsyndicate.com/secret/
SHOP installation: https://www.beastsyndicate.com/shop/
T Shirt page of SHOP: https://www.beastsyndicate.com/shop/product-category/beast-t-shirts/Appreciate your insight. Thx.
October 31, 2018 at 2:20 am #1028330Hi,
This is possible but you have to modify a WooCommerce template. The easier solution is to create a custom script that redirects a certain category link to another page.
Example:
add_action('wp_footer', 'ava_custom_script_redirect_product_cat'); function ava_custom_script_redirect_product_cat(){ ?> <script type="text/javascript"> (function() { const gift = document.querySelector('div .product-category:first-child a'); if( gift ) { gift.addEventListener( 'click', (e) => { e.preventDefault(); window.location.href = 'https://www.beastsyndicate.com/shop/'; }, false); } })(); </script> <?php }
That script will redirect the “gift cards” category to the “shop” page.
Best regards,
IsmaelNovember 4, 2018 at 9:34 pm #1029678Hi, sorry for late reply.
Where do I add this text? To the Quick CSS?
Also, if I wanted to do the same kind of redirect for another category EG: book, I’d add more code but change it accordingly?
……const book = document.querySelector(‘div .product-category:first-child a’);
if( book ) {
book.addEventListener( ‘click’, (e) => {
e.preventDefault();
window.location.href = ‘https://www.amazon.com/beast etc…………………November 6, 2018 at 6:12 am #1030219Hi,
You have to add it in the functions.php file. To apply it on multiple categories, you have to change the selector “‘div .product-category:first-child a” to something else.
// https://www.w3schools.com/css/css_pseudo_classes.asp
Let’s start with that one first.
Best regards,
IsmaelNovember 14, 2018 at 4:48 pm #1033555Hi, I accessed my Functions.php file but the only code there was ‘<?php’ – is that because I’m using a Propulsion child theme? What should I do so as to be able to insert the custom code you suggested?
Thx.
November 15, 2018 at 9:13 am #1033847Hi,
You can add that code after the < ?php opening tag. You can also install a custom function snippet plugin if you don't want to add it in the functions.php file. // https://wordpress.org/plugins/my-custom-functions/
Best regards,
Ismael -
AuthorPosts
You must be logged in to reply to this topic.