Spixxx Posted March 11, 2011 Share Posted March 11, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/ Share on other sites More sharing options...
ldb358 Posted March 11, 2011 Share Posted March 11, 2011 that's not actually how it works, often with in your theme there is a header.php file that is included, it is normally not done by replacing html Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/#findComment-1185933 Share on other sites More sharing options...
Spixxx Posted March 11, 2011 Author Share Posted March 11, 2011 I get what youre saying, but if you edit an index.php file of any wordpress site, in it you won't see the header displayed. You won't see a PHP include either, you just see: <div id="header"></div> ...and thats it. How is header.php being included? Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/#findComment-1185945 Share on other sites More sharing options...
cssfreakie Posted March 11, 2011 Share Posted March 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/#findComment-1186221 Share on other sites More sharing options...
Spixxx Posted March 11, 2011 Author Share Posted March 11, 2011 Hm, thanks but I dont think thats it. I could be wrong... Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/#findComment-1186233 Share on other sites More sharing options...
ldb358 Posted March 13, 2011 Share Posted March 13, 2011 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 »', '1 Comment »', '% Comments »'); ?></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? Quote Link to comment https://forums.phpfreaks.com/topic/230291-replace-div-with-php/#findComment-1186836 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.