Automatic excerpt is not shown with the_excerpt() command

By default, the_excerpt(), doesn’t uses the post/page content wysiwyg, it has its own textarea, that by default is not visible, you need to enable it first via screen options. After you checked this checkbox you can scroll down to the bottom of the post/page and see a new textarea, this is the excerpt. If you … Read more

the_posts_pagination() not working in wpquery

Thanks to @Buttered_Toast i’ve managed to get it work by changing: <?php the_posts_pagination( array( ‘mid_size’ => 2, ‘prev_text’ => __( ‘Back’, ‘textdomain’ ), ‘next_text’ => __( ‘Onward’, ‘textdomain’ ), ) ); ?> to: <?php echo paginate_links( array( ‘base’ => str_replace( 999999999, ‘%#%’, esc_url( get_pagenum_link( 999999999 ) ) ), ‘total’ => $postslist->max_num_pages, ‘current’ => max( 1, … Read more

require_once() if a product in woocommerce contains a tag [closed]

has_term() is a template function therefore it does not work if you use it straight in functions.php which is loaded well before knowing if the current object is a product page. So if you use it in functions.php you could do: add_action(‘template_redirect’,’my_inclusion_function’); function my_inclusion_function(){ if(is_product() && has_term(‘xyz’, ‘product_tag’)){ require_once( WP_CONTENT_DIR.’/path/file.php’); } } is_product() checks if … Read more

Use value from Ajax call in PHP function

The main problem with what you’re attempting is that variables do not persist across requests. If you set a variable on the AJAX request, that variable will not be set on the request to reload the page. The other problem is the way you’re referring to this as an “Example of function to change language”: … Read more

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