How to call html code to other pages using javascript or other codes, rather than rewriting long code?

I have a big problem here. I am new to programming, and I was wondering if you can help me with this small - or rather, the serious problem I'm here with. I work on a blog, and I have this "recently published" section in the sidebar, which consists of all my recent posts. Here is an example of what my code looks like in the section <aside>:

<ul>
<li><a href="#">Post Topic 1</a></li>
<li><a href="#">Post Topic 2</a></li>
<li><a href="#">Post Topic 3</a></li>
<li><a href="#">Post Topic 4</a></li>
<li><a href="#">Post Topic 5</a></li>
</ul>

It just gives you an idea of ​​what my recently posted section code looks like. The actual code is very long. So now the problem is that I have to copy and paste the same “long” code onto all the pages that I want to show in the Recently Published list. Can I capture this code and call it on other pages using javascript or other code? It's just that when I change the content inside the list, I need to update the list on other pages so that visitors to my site can see my latest posts. You know, just like Wordpress. Sorry my grammar. Please help me!

+4
source share
1 answer

PHP, .php , , :

<ul>
<li><a href="#">Post Topic 1</a></li>
<li><a href="#">Post Topic 2</a></li>
<li><a href="#">Post Topic 3</a></li>
<li><a href="#">Post Topic 4</a></li>
<li><a href="#">Post Topic 5</a></li>
</ul>

php , php, , . php html, :

<?php include("filename.php");?>
+1

Source: https://habr.com/ru/post/1624682/


All Articles