0

I keep struggling to understand how and why this happens: in some themes I can modify the content of a page (type page) from the dashboard, in others I can't. For instance, if I activate a default theme, say Twenty Fifteen, I can create and edit pages from dashboard. When I creat a theme from scratch, I can add a new page from dashboard, but the content added there is not showing up in the website so editing isn't possible either (my theme has only few files created: 404, footer, header, functions, index.php and style.css). When I visualize a page in the website (local), it displays the index.php content instead of the content from the dashboard. So what is the difference between the wp default themes and the one I created from zero? Please help me understand this. I didn't find any satisfying explanations on Google and posting here is kind of my last resort. Thanks in advance for any help!

0

to display page content in custom theme you should use page.php template, and call the_content() inside the loop. You can also create custom template for different pages and assign them in back end. See: https://developer.wordpress.org/themes/template-files-section/page-template-files/

  • So this is the main practice? Now, that I saw your explanation, I checked again the code behind Twenty fifteen theme and saw they used the_content() as well. – Irina Mar 15 '17 at 15:59
0

I think You should use the word press default loop for getting posts.

<?php
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        // Your loop code
         the_content();
    endwhile;
else :
    echo wpautop( 'Sorry, no posts were found' );
endif;
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.