- use Local for dev development. The theme files are saved in the path:
/Local Sites/site-name/app/public/wp-content/themes/theme-name
/. - index.php is normally used as a homepage that display all the posts and single.php displays the single post.
- php the loop:
while(have_posts()){
the_post()
}
the_post()
function keeps track of the current post.
When reaching the loop, Wordpress first determines if the page is single.php or not. If not, Wordpress retrieves multiple posts based on the requested criteria. If the loop is in the single.php page, Wordpress will only retrieve the current post.
- using html in php functions, use
?> <html here> <?php
can display the post data retrieved from Wordpress database to the page. For example:?><h2><?php the_title()?></h2><?php
displays the title of the post - adding a new page: go to the admin and click 'add new page'. The url will be shown on page setting. Update the page template in page.php file.
- page.php displays the template that will apply to all pages except the home and single page. To do conditional rendering, use if statement. For example:
if(is_page('test'){
?><h1>This is a test page</h1><?php
}
Top comments (0)