2

Hopefully this helps others who have a similar situation, I've searched and searched and cannot seem to find a solution. Perhaps I'm wording it wrong?

In short:

  1. Default posts should loop at /blog/ and the default posts to follow that path, /blog/post-title/
  2. A specific category should loop at /category/ and the posts of that category to follow that path, /category/post-title/
  3. Existing php site has functions and variables that the index.php needs to access, so it cannot run the theme engine for the homepage and doesn't need to run any unnecessary database calls except just for the 2 latest articles

I assume the folder structure can be done with wordpress in the root of the site, but I'm not sure if themes can be disabled for the homepage only. All static page information I've found (I know, php is dynamic, not static. But I need to not use the theme on the homepage while being able to use it on wordpress generated posts) points to using the wordpress theme engine.

If it can be done with the API, I would need to know how to set up an automatic routing for the permalinks.

I will update this question if answers reflect a need for clarification. I appreciate everyone's help and truly hope this can help other app developers and custom php site developers.

If there's an alternate solution to wordpress in the root that makes the folder system above work properly, that is fine. I will mark whatever answer solves this problem as correct.

  • I imagine I could add in the theme canonical tags if category is x, domain.com/x/post-title while the wordpress installation is at domain.com/blog The question would then become "how to automatically make links for the posts in the category directory?" – Howard Davis Aug 18 '17 at 20:49
  • i'm not sure what you are trying to do, WP's index.php always runs when you load a wordpress page. you can install WP in a subfolder and add links to it in your other index.php. – inarilo Aug 18 '17 at 22:49
2

Short Answer

No.

The Reason

If you take a look at the .htaccess file in the root of your WordPress installation, you will notice these few lines generated by WordPress ( If you have pretty permalink enabled ):

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Pay attention to line 5. When you make a request to a WordPress website, this rule will send it to index.php. But it appears that you want to eliminate index.php file. Even if you manage to do it via rewrite rules, there would be a million of other requests that are sent to this file by default. Not to mention this file is being used internally by WordPress.

Generally it's not a good idea to have two CMS or platforms installed into a single directory.

What To Do?

What you can do is, to install your WordPress inside a sub-directory, and then use rewrite rules to eliminate /sub-directory/ from certain pages that you need.

  • I guess I could programmatically create canonical tags as well. – Howard Davis Aug 18 '17 at 20:47
  • To be honest, your question is not clear. But generally, you should avoid having 2 platforms installed in a single directory. – Jack Johansson Aug 18 '17 at 20:48
  • It's really not a platform, just a custom coded php website with its own functions – Howard Davis Aug 18 '17 at 20:54
  • The API might have to be the solution, using it in an out-of-wordpress folder for the category posts. I could use a catchall rewrite rule for that category, but then the question would be how to automatically make links for the posts. /wordpress/default-post-title /category/category-post-title <-- – Howard Davis Aug 18 '17 at 20:57
  • This technically answers the question. I will mark it correct, but I do want to add to the question what I have done to resolve the problem first, so it can be as helpful as possible. – Howard Davis Aug 21 '17 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.