Wordpress theme development question

by 24 replies
27




Code:
 


 have_posts 
    have_posts 
      the_post
      the_content


#website design #development #question #theme #wordpress
  • The code you pasted is from the Classic theme of WordPress Version 1.5!
    Tutorials, examples at wordpress can be tricky since many of them include things from old versions.

    Try this:
    PHP Code:
    <?php
    get_header
    (); ?>

            <?php if ( have_posts() ) : ?>
                <?php /* Start the Loop */ ?>
                <?php while ( have_posts() ) : the_post(); ?>
                    <?php get_template_part'content'get_post_format() ); ?>
                <?php endwhile; ?>

    <?php get_sidebar(); ?>
    <?php get_footer
    (); ?>
    EDIT: Forgot to mention that the "get_template_part('content'.......... will pull in the content from the content.php which is now the standard in the default 2012 theme.
    • [1] reply
  • @ronc0011, this will also work and is even more minimal, but I wouldn't build a theme this way.
    PHP Code:
    <?php
    get_header
    ();
            if ( 
    have_posts() );
                while ( 
    have_posts() ) : the_post();
                    
    get_post_format();
                endwhile;
    get_sidebar();
    get_footer(); ?>
    Note that I removed the get_template_part which is not advised. get_template_part is the way to go.
    The 2012 theme is a great base example using get_template_part, custom templates, and more.
  • Try this...

    Code:
    <?php get_header() ?>
    
        <?php while ( have_posts() ) : the_post() ?>
        <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
        <?php the_content(); ?>
        <?php endwhile ?>
    
    <?php get_sidebar() ?>
    <?php get_footer() ?>
    • [1] reply
    • Not sure what you've created for files in the test theme folder, but you definately need more then index.php

      Here's a nice simple info-graphic that will give you a simple rundown.
      • [ 1 ] Thanks
      • [2] replies
  • Ok, this threads getting a little long so I'll wrap up my thoughts by pointing out these pretty bare frameworks. All are good.
    Bones
    Handcrafted WP Starter
    Starkers

    Good luck!

    Note: All the code below is only within the context of the question asked. You cannot use these codes/files to create a theme, very incomplete.
  • Wordpress theme development is a process of transforming static HTML pages to dynamic pages with PHP functions that packed in WordPress.

    So, first you have to master HTML and CSS and a little PHP, and then you are good to go.

    Tutsplus.com has free PSD to WordPress theme video tutorial series that you can learn from. It's a comprehensive tutorial from Adi Purdila. You must see it if you are learning about WordPress theme development.
  • TRY THIS,

    download another wordpress blog thesis/themes that you had used and go the the hosting cpanel admin, go to files managers, got the the theme that you currently installed and located the PROBLEM where it is then replace the codes using the codes you have just downloaded(NEW), then you done.

    hope this will work for you!
    thanks
  • As was said earlier, the required files for a WP theme are index.php, and style.css. That's ALL.

    It sounds like you are (were?) afflicted with 'blank screen syndrome'. Out-of-the-box WP installs are set to suppress errors. Open your wp-config.php file; toward the bottom, find
    Code:
    define( 'WP_DEBUG', false );
    change 'false' to 'true'. Save and upload the file.

    Your stylesheet.css file needs to have the beginning comment 'header' section, nothing more. You'll (obviously) get unstyled output, but at least you can make sure things are working.

    For the index.php file, the only essential part is the WordPress Loop. If you don't have that, you won't get any output. SOOOOO, to test, you can put this in index.php:

    Code:
    <?php
    if ( have_posts() ) :
      while ( have_posts() ) :
        the_post();
        the_content();
      endwhile;
    endif;
    Nothing more, nothing less. When you hit your URL, you should see the text of the latest posts ( that's what "the_content()" line spits out ); how many you see is determined by the setting on the Settings > Reading page in your Dashboard.

    Notice there is NO closing PHP tag ( ?> ) at the end of the file. Closing tags are unnecessary and actually go against WP coding convention.

    If your theme works, NOW you can start expanding it out to add HTML elements, etc.

    The above obviously won't get you anywhere near to a finished theme, it's kind of like WordPress's version of programming's "Hello world."

Next Topics on Trending Feed

  • 27

    So I'm working on learning theme development in Wordpress I've worked so far with tutorials from various sites claiming boosting tutorials on WP theme development. I am currently working from the Wordpress .org site and I just created an index.php page from WP.org's site i.e "The worlds simplest index page and I still get a page that doesn't display at all. Even if I go in and set a text widget in the side bar through the admin panel Also I have made post to the site under a different theme so there are post in the database. So here is the code from Wordpress.org's codex page i.e. "Worlds simplest index page.