Sometimes, you may want to customize the display of your product titles in list tables, removing the hyperlink associated with them. This tutorial will guide you through the process to Remove Links from Product Titles, using the Wishlist Table as an example.
How to Remove Links from Product Titles in List Tables? #
To achieve this customization, you’ll need to add a simple code snippet to your WordPress theme’s functions.php file.
Step 1: Locate functions.php #
- Log in to your WordPress admin panel.
- Navigate to “Appearance” and select “Theme Editor.”
- On the right-hand side, find and click on “Theme Functions (functions.php).”
Step 2: Add Code Snippet #
Copy and paste the following code snippet at the end of the functions.php
file:
add_action( 'wlfmc_table_product_details_start', function( $item, $wishlist, $atts ) {
$product = $item->get_product();
?>
<span class="product-name">
<strong>
<?php
echo wp_kses_post(
apply_filters(
'wlfmc_table_item_product_name',
is_callable( array( $product, 'get_name' ) )
? $product->get_name()
: $product->get_title(),
$product
)
);
?>
</strong>
<?php if ( in_array( 'product-stock-status', $items_show, true ) && ! $product->is_in_stock() ) : ?>
<?php do_action( 'wlfmc_table_before_product_stock', $item, $wishlist ); ?>
<span class="wishlist-out-of-stock">
<?php esc_html_e( apply_filters( 'wlfmc_out_of_stock_label', esc_html__( 'Out of stock', 'wc-wlfmc-wishlist' ) ) ); ?>
</span>
<?php do_action( 'wlfmc_table_after_product_stock', $item, $wishlist ); ?>
<?php endif; ?>
</span>
<?php
}, 10, 3 ); // Specify the number of accepted arguments (3 in this case)
This code hooks into the woocommerce_in_woocommerce_table_product_title filter and removes the link from the product title.
Step 3: Save Changes #
Click the “Update File” button to save the changes you made to the functions.php file.
Step 4: Disable “Product Name” in List Settings #
- Navigate to the plugin settings. In this example, go to Wishlist Settings.
- Inside the Wishlist Settings, find the Wishlist Page tab.
- Look for the Table Settings section within the Wishlist Page tab.
- Locate the “Items show for wishlist” option and find “Product Name.”
- Uncheck the “Product Name” option to prevent it from being displayed twice.
That’s it! The links from the product titles in the Wishlist Table (or similar list tables) will now be removed.
If you found this customization guide helpful, you might also be interested in learning how to further personalize your WooCommerce Wishlist Table. Check out our article on How to Change “Read More” and “Select Options” Text in WooCommerce Wishlist Table for detailed instructions on modifying text labels in your Wishlist Table.