Need to put a script above tag in header.php – WP 5.7.1

As @Buttered_Toest mentioned, this snippet works well. (This code goes to functions.php) function futy_widget_footer(){ ?> <script> window.Futy = { key: ‘0000000000’ }; (function (e, t) { var n = e.createElement(t); n.async = true; n.src=”https://v1.widget.futy.io/js/futy-widget.js”; var r = e.getElementsByTagName(t)[0]; r.parentNode.insertBefore(n, r); })(document, ‘script’); </script> <?php } add_action(‘wp_footer’,’futy_widget_footer’);

Setting a default text for excerpts of a particular category

Insert the following code, in functions.php of your child theme. function wpse_excerpt_for_specific_category( $excerpt ) { global $post; $category = ‘Test’; // could be name, slug, or id $excerpt_text=”some arbitrary text”; if( ‘post’ == $post->post_type && ‘publish’ == $post->post_status && in_category( $category ) ) { $excerpt = $excerpt_text; } return $excerpt; } add_filter( ‘get_the_excerpt’, ‘wpse_excerpt_for_specific_category’ ); … Read more

Illegal string offset in PHP function

You need to be validating a couple of parts about $filearray before you use it. There are some good suggestions in the comments, I think a couple of robust examples would serve you well too: Using empty() function wp_custom_attachment() { wp_nonce_field( plugin_basename(__FILE__), ‘wp_custom_attachment_nonce’ ); $html=”<p class=”description”>Upload your PDF here.</p>”; $html .= ‘<input id=”wp_custom_attachment” name=”wp_custom_attachment” size=”25″ … Read more

Show meta box only for default page template

If the “Default Template” option is selected from the Template dropdown, then WordPress will set the value of the _wp_page_template meta to default and not page.php, so that’s most likely the reason why your meta box is not showing/added. So I would use if ( in_array( $pageTemplate, array( ‘default’, ‘page.php’ ) ) ) instead of … Read more

Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args

The error happens because the filter callback (shapeSpace_disable_sitemap_post_meta()) expects to receive two parameters ($args and $post_type) and yet you call add_filter() without setting the fourth parameter to 2. So to solve the problem: // Replace this: add_filter(‘wp_sitemaps_posts_query_args’, ‘shapeSpace_disable_sitemap_post_meta’); // with this one: add_filter(‘wp_sitemaps_posts_query_args’, ‘shapeSpace_disable_sitemap_post_meta’, 10, 2);

How to remove comment count column in Posts inside the admin dashboard?

Should be work, if you use the filter manage_posts_columns. The hook is fine, see https://core.trac.wordpress.org/browser/tags/5.8/src/wp-admin/includes/class-wp-posts-list-table.php#L714 Documentation include examples – https://developer.wordpress.org/reference/hooks/manage_posts_columns/ Example: function remove_posts_columns( $columns, ‘post’ ) { unset( $columns[‘comments’] ); return $columns; } add_filter( ‘manage_posts_columns’, ‘remove_posts_columns’, 10, 2 );