Tagged: x
-
AuthorPosts
-
May 4, 2016 at 8:17 pm #913510
jbbaille2ParticipantHi there!
I would like to remove the <p> tags that wordpress puts automatically on my code (why? I am still wondering…). It happens especially on my product page (I use Woocomerce). I have tried the following solutions, without success:
1) I got this code from you guys from another topic but didn’t work:
// Remove wpautop in product pages
// =============================================================================
function remove_autop_for_product( $content ){
// check for product post type
‘product’ === get_post_type() && remove_filter( ‘the_content’, ‘wpautop’ );
return $content;
}
add_action( ‘init’, ‘remove_autop_for_product’, 999999 );
// =============================================================================2) I added to function.php this code:
remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );3) I tried the plugin disable wpautop
4) Finally, I commented on the file “default-filter.php” the lines:
filter( ‘the_content’, ‘wpautop’ ); and
remove_filter( ‘the_excerpt’, ‘wpautop’ );Nothing works! All my plugins are disable except from cornerstone and woocommerce (otherwise, my product page would be disable).
Everything is up-to-date.
You are basically my only chance not to finish this day completely depressed! Hope you can help me…
Cheers,
JB
May 4, 2016 at 8:18 pm #913511
jbbaille2ParticipantThis reply has been marked as private.May 4, 2016 at 8:20 pm #913514
jbbaille2ParticipantI just noticed that those <p> tags appear when I put two <br> in a row
May 5, 2016 at 12:38 am #913824
LelyModeratorHello JB,
Those p tags are controlled by woocommerce templates. Please check this thread for the fixed:https://community.theme.co/forums/topic/auto-p-tags-in-woocommerce/page/2/#post-841072
Hope this helps.
May 5, 2016 at 3:51 am #913990
jbbaille2ParticipantHi Lely, thank you for your answer. I put the following code (which if from your link) in my function.php file:
function woocommerce_product_archive_description() {
if ( is_post_type_archive( ‘product’ ) && get_query_var( ‘paged’ ) == 0 ) {
$shop_page = get_post( wc_get_page_id( ‘shop’ ) );
if ( $shop_page ) {
$description = wc_format_content( $shop_page->post_content );
if ( $description ) {
$tags = array(“<p>”, “</p>”, “<br>”);
$description = str_replace($tags, “”, $description);
echo ‘<div class=”page-description”>’ . wpautop($description) . ‘</div>’;
}
}
}
}It did remove the <p> tags, but it removed the <br> tags as well. So I tried the following code:
function woocommerce_product_archive_description() {
if ( is_post_type_archive( ‘product’ ) && get_query_var( ‘paged’ ) == 0 ) {
$shop_page = get_post( wc_get_page_id( ‘shop’ ) );
if ( $shop_page ) {
$description = wc_format_content( $shop_page->post_content );
if ( $description ) {
$tags = array(“<p>”, “</p>”);
$description = str_replace($tags, “”, $description);
echo ‘<div class=”page-description”>’ . wpautop($description) . ‘</div>’;
}
}
}
}Strangely enough, the <br> are still removed… which I don’t want…
May 5, 2016 at 10:33 am #914407
RupokMemberHi there,
Thanks for updating. The following code (that you mentioned below as well) should not remove
<br>tag.function woocommerce_product_archive_description() { if (is_post_type_archive('product') && get_query_var('paged') == 0) { $shop_page = get_post(wc_get_page_id('shop')); if ($shop_page) { $description = wc_format_content($shop_page - > post_content); if ($description) { $tags = array("<p>", "</p>"); $description = str_replace($tags, "", $description); echo '<div class="page-description">'.wpautop($description). '</div>'; } } } }Let’s clear your cache and check again. Make sure you don’t have any duplicate anywhere else.
Cheers!
May 5, 2016 at 9:07 pm #978030
jbbaille2ParticipantSorry it gave me a parse error when I put this code into function.php, which I really don’t understand because it is the same code that I tried yesterday, and it did nothing…
May 6, 2016 at 2:14 am #978269
RadModeratorHi there,
In that case, it’s better if I can test it directly 🙂
Would you mind providing your FTP login credentials in private reply as well?
Thanks!
May 6, 2016 at 2:32 am #978284
jbbaille2ParticipantThis reply has been marked as private.May 6, 2016 at 7:53 am #978546
LelyModeratorHello JB,
I can see that you have added the code correctly. Attached is a screenshot of the code from your functions.php file. Can you confirm that this solved? Although I can see that your product page is displaying weird. The related product is out of place. Please check any customization that might be causing that. You can try removing each custom code and add it function by function or file by file to check where it is coming from.
Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-913510 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
