WordPress - how to route all requests back to index - wordpress

I am experimenting with using WordPress and Angular JS together through the WP-API plugin. I'd like to have WordPress just serve content through a JSON API and let Angular take care of everything else; routing etc.
To do this I need all requests to my site to go back to my home page, where Angular can then read the URL and load the appropriate view. I'm using Angular UI Router to get extra options here.
I've deleted all the WordPress theme files apart from header.php and footer.php and this means URLs like http://mywordpresssite.com/route work. WordPress routes back to index and Angular reads route.
But, when I make a request like http://mywordpresssite.com/route/parameter I get sent straight back to index.
I don't know what I should be looking at to make this work. Can this be done in the .htaccess file or should I be writing custom routes into WordPress?

If i undetstand you correctly. You shuld create a theme with angular and put all your ajax stuf in functions.php file. Wordpress has suport for ajax. Then you can call that functions from angular theme in your desired format.
Sorry that I do not include some examples but I weiting from mobile.
Let me know if I got your problem

I'm working on a very similar project you can find here:
https://github.com/altrovideo/wordpress-angularjs
the way I've chosen is quite different: I've decided to abandon any front-end wordpress code, so I've written an empty sub-directory in the theme dir , then I put there my html + js + css files using https://wordpress.org/plugins/json-rest-api/
for pagination I use http://angular-ui.github.io/bootstrap and I'm using angular routing module and it works well.
Maybe the presence of wordpress headers.php files and using it as a classical wordpress theme should create the trouble.
Let me know if it helps you

Related

Wordress - How to work with non wordpress theme

I'm new to wordpress, and I want to know if it is possible to put a theme bought on shapedtheme.com for example on an existing wordpress.
And if so, how to do it. I don't know where to put the code of the theme. I saw the wordpress page builder with text, but I see tags with [] and not <>.
I saw on this thread that pages can be linked to php files. I don't see how.
I have full access to the hosting service's filesystem and can see all wordpress files.
I would also like to transpose the theme header and footer and if possible, use the theme cards to adapt to blog articles written in wordpress.
How can I do this ?
I searched for tutorials on google or related threads on SO with no luck.
Any ressource would be appreciated.
Thanks to anyone who will take the time to read/answer this post.
No, you can't use a non-WordPress theme in a WordPress installation since WordPress will look for specific templates and pass certain objects to the template to be displayed.
You could adapt it to work with WordPress, though. Here's the theming guide to get you started.
But you'll probably be able to find a WordPress-ready theme with the features you want. This is the WordPress theme directory link for themes using bootstrap.
Unless you go for a from-scratch development of a pure php theme, and you need some level of theme customization I'd strongly suggest looking into child themes, as it'll allow you to update the base theme minimizing the changes you'd have to do to yours.
The [ ] syntax you mention are shortcodes, small, safe php functions that can be executed by inserting them in the editor, templates, etc, and provide kind of an api that exposes WordPress or plugins functionality.
And regarding your link, OP already has a WordPress theme, but is looking for a way of using a different, specialized template on specific pages. This template still has to follow to certain WordPress conventions.

How to convert html website to wordpress theme?

i want to convert my html website to the wordpress. But can you please talk me that how i can convert and connect the other pages with the main page???
I'm going to start from the point of view you already have Wordpress and are ready to start.
You can't take your existing HTML website and just add it to WP.
What you need to do is to build your own custom theme, that matches your current HTML files, using the already existing WP templates and files.
Best way is to duplicate an existing theme to play/manipulate so that you don't break WP. The last thing you want to do, having no experience, is to mess with and break the default theme and be unable to get it back again without a full re-install.
RE 'connect the other pages with the main page' WP allows you to have static pages and set them as your home page and/or anywhere else you want. With these pages you can also set up different templates within your theme if you need to.
Wordpress have all this help available here:
Wordpress creating static pages and custom templates
Its not really that simple. You should read about WP theming. Here's the start:
https://codex.wordpress.org/Theme_Development
Check codes from other themes to see how to output basics. Theming has a lot of parts, but to ouput custom html you will need these files:
style.css
functions.php
index.php
single.php
With those you should have an basic blog output with core WP functionality.

Upload raw code on wordpress

I have a problem: I built a website with only raw code, and now I want to switch to a content management system like wordpress. I’d like to know how can I just upload all my code (html, css and javascript) without screwing up with the code on wordpress especially with php. Maybe do I need to find a blank theme, and for blank I mean a blank page. Any suggestion?
It depends on what you have. You should start with blank template and do part of the job, other part is to fill the content - it is possible to put there php by some plugins but it is not secure.
here you have template:
http://html5blank.com
Marco if you want to just migrate the site into wordpress and don't want to use wordpress to process any data and display it for you then migration is not difficult.
just start with any blank site ( I would start with underscores available at http://underscores.me/ ) and then just keep the index.php, functions.php and style.css to start with and then add components as and when required.
actually functions.php is not mandatory to get your WP site up and running but you can enqueue your JS and CSS files here
the topic is a very detailed one but if you need further assistance then do lemme know
I will strongly advise you to read Theme Handbook on Wordpress.org site
Hope this helps
Take care and Happy coding

How do I access to my wordpress pages?

I know wordpress store the page content inside the database. If I wanna to add content and some programming content into the page, how do I do it? Other than going to wordpress dashboard > page > all pages, is there any way to access the page file so that I can directly write the codes to it?
You can use you webhost's file manager, or your own FTP client to modify the files that wordpress is made of. Though I recommend against this; if you want to do work beyond just editing the appearance, you should design your site from scratch. If appearances are all, search for a tutorial on making wordpress themes, then apply your shiny new theme.
You'll use page.php or page-template.php file under wp-content/themes/yourthemeName/
That way you will change the file template....

Wordpress proper way of adding pages

I have been trying to figure this out now for a while but there but I haven't found any conclusive answer yet. I want to add some pages to wordpress that are static. I need to include JS script that is from a third-party login. Using JS, HTML, CSS. Very simple and basis login.
So normally what I do is create a page, empty, attach a template and put the JS/HTML/CSS/Text into that template.
However, it seems weird to create an empty page in a CMS. Is there another way, a proper way, of adding a normal page into wordpress without using the static PAGES option in the CMS?
You could just create the page and add a link to it from your WP-site. But this is only if you don't need any of the wp-functions. Also it won't show up at all in your wp-admin dashboard.

Resources