H
H
Hosting Yaroslavl2021-11-16 14:53:43
WordPress
Hosting Yaroslavl, 2021-11-16 14:53:43

What is the best way to make a website on wordpress with php code placed on each page?

We need a website-personal account with various registration forms, tables, graphs. Almost every page includes php code.

What is the best way to do it in the first place? A couple of options came to mind:

1. Put code in the theme that analyzes the url and loads content depending on the part of the page url

$url_arr = explode( '/', $url );

$page = $url_arr [3]; // https://qna.habr.com/<b>question</b>/new

$action = isset($url_arr [4]) ? $url_arr [4] : '';  // https://qna.habr.com/question/<b>new</b>

switch ($page) {
    case 'reg':
        require $dir . 'reg.php';
        break;
    case 'report':
        require $dir . 'report.php';
        break;
    case 'prefile':
        require $dir . 'prefile.php';
        break;
...
}


2. Create a Plugin with
add_action( 'init', 'pluginname_route' );
and in pluginname_route - put the url parsing function - as shown above

3. Create a Plugin with different functions and insert them as shortcodes on pages.

4. something else

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question