How do I include SVG file used as featured image?

First, you don’t need the URL but the server path to the file, you can get it with get_attached_file function, passing any WordPress attachment ID as a parameter. Then you need to load the contents of that SVG file directly, via file_get_contents function and echo it out to the page. $thumbnail_id = get_post_thumbnail_id( get_the_ID() ); … Read more

Add html link in functions.php files of the theme

You are missing a closing tag for the opening link (<a>) tag, try: function filter_woocommerce_checkout_must_be_logged_in_message( $message ) { $message=”<span>You must be <a href=”#”>logged in</a></span>”; return $message; } add_filter( ‘woocommerce_checkout_must_be_logged_in_message’, ‘filter_woocommerce_checkout_must_be_logged_in_message’, 10, 1 ); (You could also just spit out the login form right there instead of linking off, if you wanted): function filter_woocommerce_checkout_must_be_logged_in_message( $message ) … Read more

Trouble inputting variable into WP query

Combining Petar’s function and Tiago’s shortened option syntax, this works: In template: //once, in header: $i = 0; //anytime I want to run the query: $i++; $cat_query = prefix_get_wp_query($i); while ( $cat_query->have_posts() ) { $cat_query->the_post(); get_template_part( ‘template-parts/posts/content’, get_post_type() ); wp_reset_postdata(); } In functions: function prefix_get_wp_query( $i ) { if ( $i > 0 ) { … Read more

How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more