Jump to content

Replace div with php


Spixxx

Recommended Posts

How does wordpress and other similar CMS/applications replace their div elements?

 

For example, if you view the source code of a wordpress site, you will only see:

 

<div id="header"></div>

 

Where, the above code is clearing being switched out for "header.php".

 

How is this done? I believe it's php and jquery, but I would be wrong.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/230291-replace-div-with-php/
Share on other sites

i suppose with an include() function or some custom include like with joomla, it's JDoc include or something.

I bet that header is a separate file in the file system. those cms exits of hundreds of files

Here is the deafult wordpress index.php:

<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/

get_header(); ?>

<div id="content" class="narrowcolumn" role="main">

<?php if (have_posts()) : ?>

	<?php while (have_posts()) : the_post(); ?>

		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
			<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

			<div class="entry">
				<?php the_content('Read the rest of this entry »'); ?>
			</div>

			<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
		</div>

	<?php endwhile; ?>

	<div class="navigation">
		<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
		<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
	</div>

<?php else : ?>

	<h2 class="center">Not Found</h2>
	<p class="center">Sorry, but you are looking for something that isn't here.</p>
	<?php get_search_form(); ?>

<?php endif; ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

 

what do you mean edit the index.php like the theme file or through view source?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.