Put CSS inside a PHP file and include it the right way

You might try conditional classes instead. In your regular “style.css” file you would include both classes: .theme-header-title.green { color:green; } .theme-header-title.blue { color:blue; } (Tip 1: avoid !important, just use a more specific style if needed – for example, h1.theme-header-title.green.) Then in your HTML, which is likely in your “header.php” file, you’d use the Customizer … Read more

Have CSS Class Added with `is_page()` WP function

Bitwise operators expect conditionals on either side of them to evaluate to either TRUE or FALSE. If FALSE it checks the next conditional until it finds a TRUE or all conditionals have been checked. Also, the is_page() function doesn’t allow parameters to be passed in on a bitwise basis. So simply change your code to … Read more

Interrupting $html.= ‘ for IF statement

This is more general PHP than anything WordPress specific. String concatenation occurs whenever you combining two stings with the . operator. During string concatenation some basic PHP keywords will not apply and you’ll need to use the shorthand equivalent instead. In this case you can use the ternary (conditional) operator $html.= ‘<span class=”cat”>In ‘. ( … Read more

When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?

You can determine the calling files using debug_backtrace in PHP, which will give you the backtrace of the functions called and the file called from. WP core provides wp_debug_backtrace_summary, which makes doing things like this easier. Using the condition stated in your question of being called from my_file.php you could do something like this: add_filter( … Read more

Custom PHP page form data is not appearing as a wp-theme page template

The approach I usually take is to check to see if your submit input exists and construct the page based on that condition. For example, if your submit/send button was constructed similar to this: <input class=”cta” type=”submit” name=”submit_all” value=”Send message”> Then your condition check would look like: if ( isset( $_POST[‘submit_all’] ) ) { // … Read more

OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity

The problem seems to be related to missing tax or (and) to applied coupon discount. The WC_Order_Item_Product method get_total() is the discounted line item total without taxes. In this case when a coupon is used, the discount is applied to the item depending of the coupon type and restrictions. The WC_Order_Item_Product method get_subtotal() is the … Read more

How to get 2 or multiple custom post types in wordpress functions.php

In your if statement just add more conditions like this. function et_last_modified_date_blog( $the_date ) { if ( ‘post’ === get_post_type() || ‘movies’ === get_post_type() || ‘etc’ === get_post_type()) { $the_time = get_post_time( ‘His’ ); $the_modified = get_post_modified_time( ‘His’ ); $last_modified = sprintf( __( ‘Last updated %s’, ‘Divi’ ), esc_html( get_post_modified_time( ‘M j, Y’ ) ) … Read more