Function only on a specific page

define the function: // my_formatter – register custom text formatter for specified post or page function my_formatter($content) { $new_content=””; $pattern_full=”{(\[raw\].*?\[/raw\])}is”; $pattern_contents=”{\[raw\](.*?)\[/raw\]}is”; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if (preg_match($pattern_contents, $piece, $matches)) { $new_content .= $matches[1]; } else { $new_content .= wptexturize(wpautop($piece)); } } return $new_content; } Simply add the following … Read more

Disable auto-resizing of uploaded images, but only for certain filename

Please Try Below Codes: add_filter( ‘intermediate_image_sizes_advanced’, ‘prefix_remove_default_images’ ); function prefix_remove_default_images( $sizes ) { if (preg_match(‘/(hd)/’, get_attached_file( $attachment_id )) { unset( $sizes[‘small’]); // 150px unset( $sizes[‘medium’]); // 300px unset( $sizes[‘large’]); // 1024px unset( $sizes[‘medium_large’]); // 768px return $sizes; } } And You can use Stop Generating Unnecessary Thumbnails WordPress Plugin to disable for all images size … Read more

Automatically assign video ‘poster’ value to ‘filename’ for archive listing

Thanks for your help. Managed to figure out a temporary solution, should anyone else have a similar query. Temporarily edited media.php $filename = basename( wp_get_attachment_url( $attachment_id ) ); $default_types = wp_get_video_extensions(); $defaults_atts = array( ‘src’ => ”, ‘poster’ => “diary/wp-content/Pictures/posters/”.$filename.”.jpg'”, ‘loop’ => ”, ‘autoplay’ => ”, ‘preload’ => ‘none’, ‘width’ => 640, ‘height’ => 360, … Read more

Sorting table function default

You can sort this by adding ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, into the $transaction_params array. and if not working change ‘suppress_filters’ => true, See reference: here Thank you.

Show Primary Category first when I display post categories

Assuming you are using Yoast SEO plugin – I haven’t tested this, but I think you can do something like this: (Source https://pretagteam.com/question/get-primary-category-if-more-than-one-is-selected) /* Checks for a yoast primary category, if it exists move the category to the first position in the $categories array. */ function yoast_primary_cat_as_first_cat($categories) { // Check if yoast exists and get … Read more

How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]

I haven’t tested but something like this should work: function wpse70000_add_author_metabox_to_cpt_book( $args, $post_type ) { if (‘product’ === $post_type ){ unset($args[‘editor’] ); // set the ‘supports’ array } return $args; } add_filter( ‘register_post_type_args’, ‘wpse70000_add_author_metabox_to_cpt_book’, 10, 2 );