{"id":5905,"date":"2021-04-12T12:25:50","date_gmt":"2021-04-12T12:25:50","guid":{"rendered":"https:\/\/musilda.cz\/?p=5905"},"modified":"2021-04-12T12:25:50","modified_gmt":"2021-04-12T12:25:50","slug":"jak-omezit-odkaz-pouze-na-obrazek-v-loopu-produktu","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-omezit-odkaz-pouze-na-obrazek-v-loopu-produktu\/","title":{"rendered":"Jak omezit odkaz pouze na obr\u00e1zek v loopu produktu"},"content":{"rendered":"\n
Ve v\u00fdpisu produkt\u016f zahrnuje odkaz na detail produktu obr\u00e1zek, n\u00e1zev produktu i cenu. Pokud pot\u0159ebujete mezi cenu a n\u00e1zev p\u0159idat jin\u00e9 prvky, m\u016f\u017ee to b\u00fdt probl\u00e9m. <\/p>\n\n\n\n
Jak Woocommerce skl\u00e1d\u00e1 jednotliv\u00e9 prvky?<\/strong><\/p>\n\n\n\n V\u0161echno co se nach\u00e1z\u00ed mezi body 1 a\u017e 5, je uvnit\u0159 odkazu. C\u00edlem \u00fapravy je uzav\u0159\u00edt do odkazu obr\u00e1zek a sale flash a vytvo\u0159it odkaz z n\u00e1zvu produktu, tak aby bylo mo\u017en\u00e9 p\u0159id\u00e1vat prvky nad a pod n\u00e1zev produktu, bez toho, aby byli uvnit\u0159 odkazu.<\/p>\n\n\n\n Nejprve odebereme z loopu uzav\u00edrac\u00ed tag odkazu:<\/p>\n\n\n\n P\u0159esuneme jej za obr\u00e1zek:<\/p>\n\n\n\n add_action( ‚woocommerce_before_shop_loop_item_title‘, ‚woocommerce_template_loop_product_link_close‘, 20 );<\/p>\n\n\n\n Nakonec uprav\u00edme n\u00e1zev produktu, kter\u00fd je aktu\u00e1ln\u011b vypisov\u00e1n jako H2 nadpis, co\u017e lze ud\u011blat dv\u011bma zp\u016fsoby.<\/p>\n\n\n\n 1. vyu\u017eit\u00edm toho, \u017ee funkce woocommerce_template_loop_product_title je uzav\u0159en\u00e1 ve podm\u00ednce a funkci function_exists. To n\u00e1m umo\u017e\u0148uje do functions.php vlo\u017eit rovnou celou funkci a p\u0159epsat jej\u00ed k\u00f3d:<\/p>\n\n\n\n 2. Nebo funkci deregistrovat a zaregistrovat si vlastn\u00ed<\/p>\n\n\n\n A m\u00e1me hotovo. Budu se t\u011b\u0161it u dal\u0161\u00edho n\u00e1vodu.<\/p>\n\n\n\nPostup<\/h2>\n\n\n\n
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );<\/code><\/pre>\n\n\n\n
function woocommerce_template_loop_product_title() {\n echo '<h2 class=\"' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '\"><a href=\"' . get_the_permalink() . '\">' . get_the_title() . '<\/a><\/h2>';\n }<\/code><\/pre>\n\n\n\n
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );\nadd_action( 'woocommerce_shop_loop_item_title', 'musilda_template_loop_product_title', 10 );\nfunction musilda_template_loop_product_title() {\n echo '<h2 class=\"' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '\"><a href=\"' . get_the_permalink() . '\">' . get_the_title() . '<\/a><\/h2>';\n }<\/code><\/pre>\n\n\n\n