Hey @O.w. I don’t know whether this is the way to do it, but you can create a template with dummy text and images and when you want to create a new page, you can copy the code of it and make necessary edits.
If you are talking about page parts (header, footer, sidebar, etc.) you can code them separately in another file (one file for header, one file for footer, etc.) and then use the PHP include function to include it in your pages. This is a good way because if you want to edit your header, for example, it will be updated everywhere.
It works when I do it in W3schools. But when I do it in Visual studio code it does not work. I paste the include-string in my page. But nothing appears there.
Could this be because I am doing this in Visual Studio code, outside of Wordpress? Or do I have to create index.php, before the header.php works or something? Or why is no text showing up there.
Could you be a bit more specific with what you are looking for? Perhaps with an example.
It sounds like what you are wanting is what is often called a view engine. This requires a template in a markdown language, which is populated through the use of something like JavaScript/Node, or PHP (many other languages can be used).
One view engine is used in the fCC curriculum - pug. It is discussed in the Advanced Node and Express section of the course.
Hi @O.w. Have you created a separate file for header? Also, did you specify the file path correctly in the include function? Please share your code. Thanks.!
How are you running the PHP code? PHP is server-side. WAMP, MAMP, or LAMP stacks are often used for local dev (for WP specifically you can also use something like Local).
There are a lot of different templating languages it kind of depends on what programming language you want to use as well.
<div class="topmenu"> (In this section is a lot of code which is the same as the navigation bar's code at the homepage. On the homepage it works fine) </div> <br>
Are you sure that you have a local server installed on your computer? Then only you can write PHP code. Also, your first_page.html should be a PHP file and change the header.php to header.html if it doesn’t contain any PHP code.
Hmm how do I include a header.html-file in the first_page.html? The same way as with a php-file? What should I replace this code with: <?php include 'header.php';?> when including a header.html-file?
Yeah I am new to all of this. I only understand HTML and CSS kind of well.
How do I use JQuery for this?
And why does this work when I do it through Local flywheel-wordpress-coding? But not in Visual studio alone? Is that because the lack of a server or something?
I have no idea How can I tell? (I am a noob to all this stuff) trying to build a website. It worked fine when I did this in every single page at the top navigation section. But I want to create a structure/template generic for all pages. So that I could just alter that one page for all of the rest to follow, if I need to change something.
I am unsure of the WAMP, MAMP, or LAMP stacks. because I don’t know what those are
First of all, you need to install a local server as PHP is a server-side language. I use XAMPP. When you install it, PHP is installed in your computer. If PHP is not installed in your computer, you can’t do this.
If you don’t understand PHP, then try using jQuery method. But, trust me, using PHP is good for this.
I want to to try that. I have Mac. Should I download XAMPP? Will it work automatically after that or do I need to create a pathway/connection or something?