Need help on a small wordpress/ WooCommerce code snippet

Ολοκληρωμένο Αναρτήθηκε Πριν 4 μήνες Πληρώθηκε κατά την παράδοση
Ολοκληρωμένο Πληρώθηκε κατά την παράδοση

I created a code snippet to insert random woocommerce products between paragraphs on all blog posts.

Somehow there is a bug that creates 2 issues:

1. When the code snippet is active, youtube videos are not embedded anymore

2. The displayed woocommerce products are kinda messed up, check attached images

Looking for a solution.

sample: [login to view URL]

code:

function addParagraphs($content) {

if (is_single() && !(is_product())){

$the_category = get_the_category()[0];

switch($the_category->name) {

case 'Facebook':

$custom_str = '[product_category category="facebook" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Threads':

$custom_str = '[product_category category="threads" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Instagram':

$custom_str = '[product_category category="instagram" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'LinkedIn':

$custom_str = '[product_category category="linkedin" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Soundcloud':

$custom_str = '[product_category category="soundcloud" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Spotify':

$custom_str = '[product_category category="spotify" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'TikTok':

$custom_str = '[product_category category="tiktok" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Twitter':

$custom_str = '[product_category category="twitter" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'Twitch':

$custom_str = '[product_category category="twitch" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

case 'YouTube':

$custom_str = '[product_category category="youtube" per_page="2" columns="2" orderby="rand" order="rand"]';

break;

default:

$custom_str = '[products per_page="2" columns="2" orderby="rand" order="rand"]';

break;

}

// you can add as many as you want:

$additions = array(

"<p>$custom_str</p>",

'<p>[Sassy_Follow_Icons]</p>',

"<p>$custom_str</p>",

"<p>$custom_str</p>",

"<p>[publishpress_authors_box layout='ppma_boxes_476999']</p>",

);

$content = get_the_content();

$output = ''; // define variable to avoid PHP warnings

$parts = explode("</p>", $content);

$count = count($parts); // call count() only once, it's faster

for($i=0; $i<$count; $i++) {

$output .= $parts[$i] ?? '';

$output .= '</p>';

$output .= $additions[$i] ?? '';

// non-existent additions does not concatenate

}

return $output;

}

else {

return $content;

}

}

add_filter('the_content','addParagraphs');

WordPress PHP JavaScript CSS WooCommerce

Ταυτότητα Εργασίας: #37564976

Σχετικά με την εργασία

83 προτάσεις Απομακρυσμένη εργασία Ενεργό Πριν 4 μήνες

Ανατέθηκε στον:

ahmedlakhyar

Hi Max, It appears that your code is interfering with the embedding of YouTube videos and is causing issues with the displayed WooCommerce products. To address this, I'm already thinking of some adjustments to your co Περισσότερα

$30 USD σε 1 μέρα
(32 Αξιολογήσεις)
5.6

83 freelancers κάνουν προσφορές κατά μέσο όρο $139 για αυτή τη δουλειά

AMsolutions1

Hi there, So you want that youtube videos should be embedded and should look clean and formatted. Right? Please initiate chat so that we can discuss and proceed. With regards, Manoj

$170 USD σε 2 μέρες
(249 Αξιολογήσεις)
8.1
vyasrohan

Hello There, I have seen your site and code carefully. I am confident that I will solve issue in your site. I can start right from today and complete this in 48 hours. Thanks

$200 USD σε 2 μέρες
(564 Αξιολογήσεις)
8.3
Speedycom

Hi. I can help you with this and I'm ready to start right now. Please don't hesitate to check my feedback page and see what other clients write about me. Thank you. Cheers. Alex

$100 USD σε 1 μέρα
(337 Αξιολογήσεις)
7.9
navneet008

Hello there! My name is Rajesh, and I'm an experienced professional web developer and designer. I understand that you need help on a code snippet to insert random WooCommerce products between paragraphs on all blog pos Περισσότερα

$100 USD σε 2 μέρες
(530 Αξιολογήσεις)
7.9
Zahi9

Good Day, Honorable sir, You can try my service. My name is Zahidul, I have reviewed your job description "Need help on a small wordpress/ WooCommerce code snippet " as well, I found my skills relevant to your project Περισσότερα

$80 USD σε 2 μέρες
(336 Αξιολογήσεις)
7.5
mascotindia123

Hello Employer, Hope you're doing well. I have read your project description regarding "Code snippet to insert random woocommerce products between paragraphs on all blog posts" & it can be done as I'm an expert having Περισσότερα

$140 USD σε 7 μέρες
(338 Αξιολογήσεις)
7.8
freshonsolutions

Hello, I have done similar solution for a client some time back and know that such issues happens in implement this way. I can look into your site and try to fix it but if HTML structure of blog post is complex then i Περισσότερα

$225 USD σε 3 μέρες
(209 Αξιολογήσεις)
7.7
thedeveloperteam

Hi I am an expert Woocommerce developer, will fix the issue with current code snippet so videos are shown and products are not messed up. Let's chat to discuss and finalize. Thanks

$100 USD σε 1 μέρα
(86 Αξιολογήσεις)
7.3
vashishtrupinder

HEllo, I can help you to code snippet to insert random Woocommerce products between paragraphs on all blog posts. I have gone all the details and attachment so I am pretty much sure that I can do this .I have some ques Περισσότερα

$100 USD σε 1 μέρα
(209 Αξιολογήσεις)
7.5
topithub

Need help on a small wordpress/ WooCommerce code snippet My name is Rana, and I'm contacting you from (TopIThuB). Hope you are doing well; we have checked your project description we are best for this project. Kindly Περισσότερα

$190 USD σε 2 μέρες
(50 Αξιολογήσεις)
7.2
NeOLiO

Hello, I have checked the website and attachments. I am Certified wordpress programmer. I have read the code. It has code issue in the shortcode rendering and the youtube, filter update logic is not implemented. I will Περισσότερα

$120 USD σε 2 μέρες
(210 Αξιολογήσεις)
7.3
vipworks

Dear Client, I am an expert in WordPress and web development technologies. I have carefully reviewed your requirements for fixing the bug in the code snippet you created to insert random WooCommerce products between p Περισσότερα

$140 USD σε 5 μέρες
(305 Αξιολογήσεις)
6.9
kevinmartialex

Hello. I am ready to start work right now. I am very familiar with wordpress, woocommerce website building and theme & plugin development, Child theme development, payment gateway & API integration, custom widget & c Περισσότερα

$100 USD σε 1 μέρα
(62 Αξιολογήσεις)
6.5
tanveerk0956

Hi, Please share login details. I am ready to start work right now. I understand how can it is, and can get this fix for you quickly! I'm a full-stack web developer, designer, and SEO expert, with over 6+ years of expe Περισσότερα

$30 USD σε 1 μέρα
(217 Αξιολογήσεις)
6.4
ClearPoint

Hello, my name is Adam Levinson and I am a top rated plus freelancer with 15+ years of experience in various technologies such as JavaScript, PHP, WordPress, Linux/Windows system administration and more. I understand y Περισσότερα

$100 USD σε 1 μέρα
(82 Αξιολογήσεις)
6.5
mdsayeedullah

Hey there! My name is MD. SAYEED, and I am a freelancer with extensive experience in graphics and web design, specifically WordPress and Shopify development. I understand that you are looking for help on a code snippet Περισσότερα

$140 USD σε 3 μέρες
(120 Αξιολογήσεις)
6.4
raushan790

Hello there! My name is Raushan and I'm an experienced freelancer with 10 years of experience in web design and development. I understand that you are looking for someone to help you solve the issue with your code sni Περισσότερα

$50 USD σε 2 μέρες
(120 Αξιολογήσεις)
6.0
usmanrauf99

Hello Mate, I have a strong background in WordPress development and troubleshooting Woo Commerce-related challenges. The code snippet you've implemented seems to interfere with the proper embedding of YouTube videos w Περισσότερα

$200 USD σε 4 μέρες
(87 Αξιολογήσεις)
6.3
mdzumanfarhad91

Hello, I can fix your Website bug asap. I would love to discuss how I can help you with your project. Please feel free to contact me for more information or for a consultation about how I can help you with your code s Περισσότερα

$60 USD σε 2 μέρες
(36 Αξιολογήσεις)
5.5
marjanahmed13

Hi! My name is Marjan and I'm here to offer you my services as a skilled applicant with over a decade of experience working on Freelancer.com. I believe I am the best fit candidate for this project due to my extensive Περισσότερα

$140 USD σε 7 μέρες
(30 Αξιολογήσεις)
5.6