Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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

    #1026799

    Hey ATX,

    Could you please attach a mockup of what you’re trying to achieve?

    Best regards,
    Victoria

    #1027198

    Hi 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.

    #1028330

    Hi,

    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,
    Ismael

    #1029678

    Hi, 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…………………

    #1030219

    Hi,

    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,
    Ismael

    #1033555

    Hi, 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.

    #1033847

    Hi,

    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

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.