ng-wp-theme icon indicating copy to clipboard operation
ng-wp-theme copied to clipboard

"no post found" in production

Open hussain-t opened this issue 7 years ago • 8 comments

Hi, Thanks for the wonderful stuff.

I have downloaded the zip file and edit the base url and built it. Then i pasted the dist folder in my WordPress localhost. I had to edit all js and css compiled files paths' in dist/index.html. Then i activated the theme in WordPress dashboard, when i go to the website it shows "no post found". But in my Angular localhost:4200 i can see the posts!

Please help me to fix this.

Hussain.

hussain-t avatar Mar 31 '17 09:03 hussain-t

Hey Hussain, when you built for production, did you add a deploy-url? Production build command should look like ng build --prod --deploy-url="/wp-content/themes/{THEME_DIRECTORY_NAME}/dist/". Besides that, in the environment.prod.ts file, make sure it's pointed correctly at your site. I just tested it and I'm getting posts back. Hope that helps!

stuartwk avatar Mar 31 '17 16:03 stuartwk

Hi there,

i have the same problem. For the local apache server i use Xampp.

What i did:

  1. Downloaded your repo as .zip
  2. Installed a new wordpress (4.7.3) to C://xampp/htdocs/mg/
  3. Copied all files from the repo to C://xampp/htdocs/mg/wp-content/themes/wpng2/ {ALL YOUR FILES HERE}
  4. Runned npm install
  5. Updated the environment.ts:
export const environment = {
  production: false,
  wpBase: '//localhost/mg/wp-json/wp/v2/'
};
  1. Updated the environment.prod.ts:
export const environment = {
  production: true,
  wpBase: '//localhost/mg/wp-json/wp/v2/'
};
  1. Build the project from C://xampp/htdocs/mg/wp-content/themes/wpng2/:

ng build --prod --deploy-url="/mg/wp-content/themes/wpng2/dist/

  1. Serving localhost/mg/ with Xampp apache and sql server running:

Doppia East

no post found

  1. Serving the app with ng serve -o:

Doppia East

  • Random blog post
  • Hello world!

There are no errors in the chrome dev tools console. Any ideas?

Greetings

malv7 avatar Apr 07 '17 12:04 malv7

This is kind of odd. Maybe in the deploy URL, try using the full path for localhost? You can also check the dist folder the build creates. Inside of index.html, check the paths on the javascript files to see if they are pointing to your localhost setup.

Just a note, if you are running on localhost, I'm assuming this is for dev, so it's probably fine just using ng serve. The instructions for production are more geared towards launching on a live site. But you're right, you should be able to run a production build and have it work on localhost too.

stuartwk avatar Apr 08 '17 02:04 stuartwk

hi, i am present the same problem mentioned previously. in the console i can see "Failed to load resource" in "posts?slug=wordpress". Ii never call the posts with this slug

uclides avatar May 02 '17 16:05 uclides

hey @stuartkuentzel, cool work on this! i'm still new to angular so i'm not super familiar with everything, yet!

I have the same problem as everyone above where i get the 'no post found' line on my localhost running MAMP.

the slug used to access my site eg. localhost:8888/{slug} is being used for posts?slug=. I did a little test and made a post with the same name as {slug} and the post showed up. I don't actually know how to fix this but I suspect it will work fine on a live site?

mr-moto avatar May 03 '17 10:05 mr-moto

Hi, @mr-moto I fixed this issue changing the route in the app-routing.module.ts file. in my case is testing with tomcat. My route is http://localhost:8181/wordpress then in the file add this code:

const routes: Routes = [ ... { path: 'wordpress', component: PostListComponent, pathMatch: 'full' } ];

I hope I help you

uclides avatar May 03 '17 12:05 uclides

Hey, I just tried to replicate this using MAMP, and still couldn't get it to break. Just setting the path in environment.prod.ts and adding the --deploy-url to the build and for me it's working.

If you guys think you got a fix, since this seems to be a problem for a couple people, feel free to make a pull request.

stuartwk avatar May 07 '17 21:05 stuartwk

Hi there,

For the people who are trying to run this in a local XAMPP/MAMP server as a production server just change the index.html base tag to:

<base href="/{your_site_folder_name_here}">

so that your folder name isn't read has a url parameter.

At least that's how I fixed it.

Hope it helps.

NunoAraujo avatar Sep 29 '17 23:09 NunoAraujo