grahammtbr
Forum Replies Created
-
Forum: Plugins
In reply to: [GenerateBlocks] Problems with css generationI’m also having this same issue. CSS is only generated for Pages, not Posts or CPT’s. I’ve tried added CPT’s, and even individual CPT pages to the generateblocks_do_content filter, but it’s still not working. I’ve doubled checked that the correct content is being received by the filter.
I can confirm it works on my staging & production server.
My local install is from 10Up, https://10up.github.io/wp-local-docker-docs/, and it’s a fairly standard WordPress docker setup (and matches WP’s suggested NGINX settings). If the issue is with “pretty permalinks”, then it suggests an issue with locally hosted NGINX (as I’ve noticed this seems to be fairly different to Apache), so I did some digging…
The issue is in /blocks/index.php.
$wp_post = get_post( url_to_postid("https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']), '_wpg_def_keyword', true );
I’m not a server expert, but as far as I can tell it should be,
$wp_post = get_post( url_to_postid("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), '_wpg_def_keyword', true );
to work correctly with NGINX localhost.
I read a bit of PHP docs and learnt SERVER_NAME will return the spoofed hostname by default under Apache2 unless spoofing is specifically turned off, which is probably why is works for some people, while NGINX returns ‘localhost’ instead of the hostfile domain name (and therefore wp_post returns a post ID of 0 and unsets the JS file).
Making that change fixed my issues. I tested on a live site as well with no problems.
Yes, on localhost using pretty permalinks.
Hi Munir,
There’s no cache, this is on a local development site (Docker, NGINX, PHP 7.4), and I did clear my browsers cache (tried both Firefox and Chrome). No plugins, and tried with Twenty Twenty, and Twenty Nineteen (and my own theme).
Build.js is not being called on the frontend, I think that’s what’s missing. When I enqueue it it still doesn’t work, but console complains that lodash is not defined.
Graham
get_fields performance was fixed quite a while ago. It preforms as fast as get_post_meta now.
Bill Erickson was probably the loudest about this, https://www.billerickson.net/advanced-custom-fields-frontend-dependency/ See the update at the top of his post.