Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building WordPress theme on Windows #1531

Closed
cr101 opened this issue Feb 12, 2017 · 6 comments
Closed

Building WordPress theme on Windows #1531

cr101 opened this issue Feb 12, 2017 · 6 comments

Comments

@cr101
Copy link
Contributor

cr101 commented Feb 12, 2017

I am new to CRA and a React beginner.
I am planning to build a WordPress theme using React + Redux and the WP API. I will be using the Foxhound theme as a guide.
I currently have a WordPress website running on my local Windows 10 machine using Wampserver 3.0.8 (Apache 2.4.23, PHP 7.0.11, MySQL 5.7.15).
I am using an Apache virtual host and the WordPress website loads at mywebsite.dev

Does CRA support named URLs e.g. mywebsite.dev as opposed to localhost:3000?

@gaearon
Copy link
Contributor

gaearon commented Feb 12, 2017

I think you should be able to use HOST and PORT environment variables for this.
See Advanced Configuration.

Does this help?

@cr101
Copy link
Contributor Author

cr101 commented Feb 12, 2017

@gaearon Yes that helps. Thanks.

The other question I have is: does anyone have any examples/tutorials of how to build only parts of a WordPress theme as a Single Page App instead of the entire website to get the full SEO benefits as discussed in this blog post?
SEO is a challenge for all websites built as a SPA.

@viankakrisna
Copy link
Contributor

@olivia101 for SEO i think you could do a user agent switching. It's similar to what prerender.io does. But instead of an external service you could feed the bots to wordpress' own theme engine. I'm building one myself currently.

@gaearon
Copy link
Contributor

gaearon commented Feb 14, 2017

I’m going to close as this is not directly actionable in this repo, but feel free to continue the discussion!

@gaearon gaearon closed this as completed Feb 14, 2017
@viankakrisna
Copy link
Contributor

for anyone who needs user agent switching for bots in WordPress / PHP:

if (
    strpos($_SERVER["HTTP_USER_AGENT"], "baiduspider"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "twitterbot"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "rogerbot"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "linkedinbot"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "embedly"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "quora link preview"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "showyoubot"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "outbrain"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "pinterest"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "slackbot"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "vkShare"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator"] !== false ||
    strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false
) {
    //render your server rendered markup for bots
} else {
    //render your SPA
}

put this in your theme's index.php

reference: https://gist.github.com/thoop/8165802 and https://prerender.io/documentation/install-middleware

@cr101
Copy link
Contributor Author

cr101 commented Feb 15, 2017

@viankakrisna Thank you, I'll give that a go.

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants