Display text of price (minus 20%) on every product page in a sentence.

Assuming you would put this in a woocommerce template file, wherever you want it to display: <?php global $product; $regular_price = esc_attr( $product->get_display_price() ); $discount = 20; $currency = esc_attr( get_woocommerce_currency() ); $new_price = ($regular_price * $discount) / 100; echo ‘Get this product for ‘.$new_price.$currency.’ with (Promo code)’; ?> Untested, but should do the trick.

Post that populates itself (almost) automatically using data from imported excel file

Sounds like a single “book” post type would be most appropriate. You could then add custom postmeta, which does not require Advanced Custom Fields. I would create the post type and custom fields first, test them out to make sure they’re saving appropriately to the database. Then, you can do a foreach loop for each … Read more

RSS feed including post updates

what you could possibly do, is set up a post dedicated to the list, then on the post / page do an include to retrieve that list onto it. <?php $my_id = 7 <—this would be the post / page id you set up on for the list; $post_id_7 = get_post($my_id, ARRAY_A); $title = $post_id_7[‘post_content’]; … Read more

How to delete posts older than one year with post meta, post attachments and files?

I find-out an way, when working on a cron related project. 1. Install and active [WP Crontol plugin][1] 2. Go to Tools->Cron Events. 3. Create new cron job at `Add PHP Cron Event tab. Here, I use PHP code global $wpdb; $posts_table = $wpdb->prefix . ‘posts’; $term_relationships_table = $wpdb->prefix . ‘term_relationships’; $postmeta_table = $wpdb->prefix . … Read more

Help with is_page() and calling css for specific pages in a Child Theme

The first parameter of wp_enqueue_style and wp_register_style is used to register the stylesheet for later use. So, you can register it early and later call it just specifying it’s first parameter. In this case you are registering and enqueueing the stylesheet td-theme-child, which file is style.css. After that, if the conditional passes, you are registering … Read more

foreach argument to get specific file types getting too many returns

You can add ‘post_mime_type’ => ‘…’ to your $args, as in: $mime_types = array (‘audio’, ‘application’) ; $args = array ( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘post_mime_type’ => $mime_types, ) ; $query = new WP_Query ($args) ; See Mime-Type Parameters for more info. It’s not documented very well but the mime-types you set can … Read more

Using Switch Statement to Change Image According to Last Digit of Topic ID

I would try something like this: function bg_image_topic_titlearea() { if ( ! function_exists( ‘bbp_get_topic_id’ ) ) { return false; } if ( ! $letztezifferimgs = bbp_get_topic_id() ) { return false; } $letztezifferimgs = substr( $letztezifferimgs, – 1 ); // switch … return true; } I would recommend checking to make sure the function call (bbp_get_topic_id();) … Read more