asked    Hermosa     2018-10-22       javascript       106 view        2 Answers

[SOLVED] Integrate Single Page application into WordPress

I have lots of basic single page applications which have html, css, js files I would like to publish them on wordpress.

I can add them like external website but when I used this, I have to add all static parts (header, menu, footer etc) to the app.html file. And I have to do this for each application. This is not sustainable and good solution for sure. This is why I am looking for some way to add this page after menu in wp like other pages.

I would like to give you folder hierarchy to concrete the problem.

  • || - apps
  • || - || - app1
  • || - || - || - app1.html
  • || - || - || -
  • || - || - || -
  • || - || - || - img
  • || - || - || - || - img11.png
  • || - || - || - || - img12.png

  • || - || - app2
  • || - || - || - app2.html
  • || - || - || - app2.js
  • || - || - || - app2.css
  • || - || - || - img
  • || - || - || - || - img21.png
  • || - || - || - || - img22.png

I would like to add apps folder to the wp and create pages by using admin panel if it is possible.

I tried this (to add only one app), it calls html but js and css didnt work. (js and css files were linked inside html files)

<?php /* Template Name: App1 */ ?>
<?php get_header(); ?>

<?php include 'apps/app1/app1.html'?>

<?php get_footer(); ?>

edit: When I directly integrated css & js codes to html file internally, the system works properly. However when I tried to add them externally the system doesnt work.

<link rel="stylesheet" href="">
<script src=""></script>

When I inspected codes (CTRL + Shift + I) I saw the problem, how can I fix this path ?

<link rel="stylesheet" href="">

  2 Answers  

        answered    Richard     2018-10-22      

You need to use .. to indicate the parent directory:

Try this

<?php /* Template Name: App1 */ ?>
<?php get_header(); ?>

<?php include '../apps/app1/app1.html'?>

<?php get_footer(); ?>


        answered    Antonio     2018-10-22      

Install apps folder directly inside wp-content folder

Inside .html file, I changed this;

<link rel="stylesheet" href="">
<script src=""></script>

With this;

<link rel="stylesheet" href="">
<script src=""></script>

And Php file

<?php /* Template Name: App1 */ ?>
<?php get_header(); ?>
<?php include 'wp-content/apps/app1/app1.html">'; ?>
<?php get_footer(); ?>

This solves the problem however still I am not sure whether this is reasonable solution from maintenance point of view.





Your Answer





 2018-10-22         Giles

Pandas - expand dataframe using daterange

I have the following dataframe: name from amount days A 7/31/18 200 1 B 7/31/18 300 1 C 7/30/18 200 1 D 7/27/18 100 3 ...... G 7/17/18 50 1 H 7/13/18 150 4I'd like to expand it to this, where days does not equal 1: name from amount days A 7/31/18 200 1 B 7/31/18 300 1 C 7/30/18 200 1 D 7/29/18 100 3 D 7/28/18 100 3 D 7/27/18 100 3 ...... G 7/17/18 50 1 H 7/16/18 ...
 python                     2 answers                     82 view
 2018-10-22         Edith

Tweepy Cursor Search - User input and Mention

I'm trying to have a user input search and a set search parameter in the api.search function of tweepy. Essentially I want it like this: print("input search term to search within Tesla tweets")keyword = input()print("Thanks!")print("Tweets are cooking in the background now...")# create list to append tweets totweets = []# append all tweet data to listfor tweet in tweepy.Cursor(api.search, q="@tesla" + keyword, tweet_mode="extended", count=10000, since="2018-08-01").items(): tweets.append(tweet) word_string = repr(tweet)But that won't work it jus...
 python                     1 answers                     84 view
 2018-10-22         Denise

jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'posted'

I'm new to programming and recently a friend of mine gave me a project to work on in order to get myself familiar with the programming environment and language (python in this particular example).https://www.youtube.com/watch?v=QnDWIZuWYW0 I used this video as a beginners tutorial to help me understand how i'm supposed to proceed with my personal project. the code i wrote is exactly how it is written in the video, and i get an error.from flask import Flask, render_templateapp = Flask(__name__)posts = [ { 'author': 'Alon Salzmann', 'title': 'First Post', ...
 python                     2 answers                     83 view