Removing unnecessary CSS and JS code from wp_head()
Removing unnecessary CSS and JS code from wp_head()
Removing unnecessary CSS and JS code from wp_head()
why does add_action need to go into main plugin file to be activated instead of using the register_hook_activation()? You’ve misunderstood how WordPress and PHP work. Any code that does not write to the database or a file is not persistent, and add_action() does not do either. Any time a WordPress page is requested by the … Read more
Execute a PHP Function when a Block is used and access it’s attributes
and <meta property="og:title"
If The Goal Is Adding It When a Block Is Used WP will automatically add JS if you specify the file in block.json, specify a viewScript and it will register and enqueue that script when the block is used ( and only when it’s used ). Likewise for CSS you can specify style. Both take … Read more
this question is too generic to be answered. You need to debug and understand where those 2 meta are created. As a first step I would disaable all the plugin and enable one by one to see if it’s coming from a plugin.
Sure, we can modify meta tags in WordPress using actions and filters. The <title> tag is pretty easy, WP already has a filter called document_title_parts that allows you to manipulate the title before being outputted to the page. Here’s a simplified example of using it : add_filter( ‘document_title_parts’, ‘filter_document_title_parts’, 10, 1 ); function filter_document_title_parts( $title_parts … Read more
I found answer i do not need to return value, i must echo it. So my function should look like: function custom_description(){ echo ‘<meta name=”description” content=”cococo” />’; } This works !
Your php code block is not properly formated. You currently have this <php? wp_head(); ?> Notice the opening php tag <php?, a correct php tag is <?php. A less than symbol < followed by a question mark ? followed by the word php. So a proper php block would look like this <?php // Your … Read more
If you’re in the admin and you want to “read” the <head /> of the frontend, you can make an internal HTTP request and scrape the response HTML: $url = home_url(); $request = wp_remote_get( $url ); $body = wp_remote_retrieve_body( $request ); $dom = new DOMDocument(); libxml_use_internal_errors( true ); $dom->loadHTML( $body ); $xpath = new DOMXpath( … Read more