Customize, Develop WordPress Theme from Scratch, Loop Through WP Posts and Pages, Get Post Content
In this WordPress beginners guide 2023, we take a look at how to Customize, Develop WordPress Theme from Scratch, Loop Through WP Posts and Pages, Get Post Content using PHP WordPress Functions. In this lesson, we go over creating templates for our different page types that are able to use the famous WordPress Loop which we learned in the last lesson, the while loop. In our index.php file, we use the while loop to loop through our posts using the have_posts() function. Within our while loop, we are able to get post data from our WordPress site using the_post() function and we then make some room in between our while loop so we can add some HTML that will dynamically get our post title using the_title() function which returns the current blog post title we are in within our loop. We link to that blog post by surrounding our title with an "a" tag that we dynamically change each iteration through the loop using the_permalink() function. We then learn that we are able to create a template for our posts page by creating an additional file we call single.php since we learn that WordPress will check in our Theme Folder for a file named single.php to use for our blog posts. We copy and paste our index.php code and paste it to our single.php removing the link around the post title since in the single blog post this would not make sense. We lastly learn how to customize our pages in WordPress by creating a file page.php which will be used to power any of our WordPress pages. Thanks for watching how to Customize, Develop WordPress Theme from Scratch, Loop Through WP Posts and Pages, Get Post Content.