Trying to get this function to show below the content

If it was me I’d not echo the text I’d make it a variable e.g. $additional_text = “” then at the end of the function return $additional_text;. if (have_posts()) : while (have_posts()) : the_post(); $additional_text=”<div class=”timeline”>”; $additional_text .= ‘<a href=”‘; $additional_text .= the_permalink(); $additional_text .= ‘”><h3>’; $additional_text .= the_title(); $additional_text .= ‘</h3></a>’; $additional_text .= ‘</div>’; … Read more

Add custom css to theme

You need to make sure that your css goes between style tags. Try changing this line: .btn { background-color:<?php echo esc_attr($btn_color);?>; } <?php to <style>.btn { background-color:<?php echo esc_attr($btn_color);?>;</style> } <?php

Woocommerce – Checkout error message

you can try it for address not required . add_filter( ‘woocommerce_billing_fields’, ‘wc_optional_billing_fields’, 10, 1 ); function wc_optional_billing_fields( $address_fields ) { $address_fields[‘billing_address_1’][‘required’] = false; $address_fields[‘billing_address_2’][‘required’] = false; return $address_fields; }

Need to use an external variable inside a function

You’re right that using globals is inelegant at best. There are almost always better solutions that don’t depend on global variables. However, if you pause execution within your file_pull() function (e.g. using a debugger), or even just print $GLOBALS to your php error log within the scope of your function, does your $type variable show … Read more

Parse error: syntax error, unexpected ‘endforeach’ (T_ENDFOREACH) in [closed]

When you use endforeach;, you have to use : instead off { when starting the foreach. <ul class=”project-extension-side-link”> <?php foreach($projectextensions as $projectextension) : // <— ?> <li <?php echo ($section==’project-extension’ ? ‘class=”active”‘: ”); ?>><span>Project 1</span></li> <li><a href=””><?php echo $projectextension->post_title; ?></a></li> <li><a href=””>Project 3</a></li> <li><a href=””>Project 4</a></li> <li><a href=””>Project 5</a></li> <li><a href=””>Project 6</a></li> <?php endforeach; ?> … Read more

Add product to cart from functions.php

I’ve figured it out function my_custom_function() { global $woocommerce; if ( $_SERVER[‘REQUEST_URI’] == ‘/checkout/?a=b’ ) { $woocommerce->cart->add_to_cart( 90759, 1 ); // exit; } } add_action( ‘init’, ‘my_custom_function’, 7 );

how to handle multiple forloop?

You can do something like this public function getStuffDone() { $order_ids = array( 358,368 ); $items = array(); // contains the names foreach ( $order_ids as $order_id ) { $order = wc_get_order( $order_id ); foreach ( $order->get_items() as $item_values ) { $items[ $order_id ][] = $item_values->get_name(); // add the name to the array } } … Read more