dqwr32867 2019-07-28 14:43
浏览 84

如何将带有ajax请求的php页面添加到wordpress中的另一个php?

I have two php files- index.php ajax.php

The index.php file contains html, javascript and css along with bootstrap and jquery library.

These are my previous website pages, which are stand-alone, single page website.

How can I add these to a wordpress site so that when the user visits a link, it shows content of index.php and from index.php, the jquery search to ajax.php is performed?

I tried making custom templates and created a page with it, but it does not search for ajax.php file for the ajax requests.

How can I do it? I am a developer myself, I understand PHP, but not the wordpress cms.

  • 写回答

1条回答 默认 最新

  • doudou32012 2019-07-28 15:09
    关注

    There are two approaches. You can either change index.php to another file, say, "search.php", and it will co-exist with Wordpress and everything will work.

    Or, you can "transplant" your index.php into the Wordpress eco-system:

    1. create a "page" in wordpress so that you'll have a container.
    2. in "functions.php", create a custom shortcode with the add_shortcode function. (you could create a plugin as part of the theme so that when you upgrade Wordpress your changes stay compatible, but for now you can just change functions.php)
    3. in the content of the new page, use the shortcode.

    You can move the jQuery code, HTML markups, etc. into the definition of the shortcode. You might run into some styling collisions but for the most part it should work.

    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况