Support » Fixing WordPress » trying to use Template tags and the loop

  • Ok im new to wordpress and php,
    What im trying to do is pull Posts with their name, date and content. but i just cant understand how to use the tags and loop because i keep getting some Fatal error and i believe its because i did move around some files.

    i know the way my files are set up. but how do i set where for the get_header or something to look because i installed wordpress as its our directory. such as and i want my index of to pull posts from wordpress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • To make WordPress available at just change in Settings->General, the Blog address (URL) to and put this index.php file in your web-root folder (it is the same folder that contains the wordpress folder)

    /* Short and sweet */
    define('WP_USE_THEMES', true);

    Then update your permalinks in Settings->Permalinks.

    all the code did that you gave me just displays the entire wordpress blog onto my site.
    i had changed the real blog page to
    and the login page is at it didnt affect anything. i still just have no idea how to pull only post title, time and content.

    This is code for example only if you copy it from here with the ‘ included it won’t work.Don’t copy any ‘

    if your wordpress is installed at /blog
    try ‘<?php
    /* Short and sweet */
    define(‘WP_USE_THEMES’, false);

    I assume you aren’t using wordpress to “run” the home page so I assume you need to use false. then try this code in the file that runs the home page for your website at Post this before the loop:

    call header
    ‘<php get_header.php();?>’
    ‘<div id=”content”>’
    $limit = get_option(‘posts_per_page’);
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(‘showposts=’ . $limit . ‘&paged=’ . $paged);
    $wp_query->is_archive = true; $wp_query->is_home = false;
    This is where the loop starts:
    ‘<?php if (have_posts()) : while (have_posts()) : the_post(); ?>’
    ‘<div class=”post”>’
    this outputs the post title
    ‘<h2 id=”‘post-‘<?php the_ID(); ?>'”>”‘” rel=”bookmark” title=”Permanent Link to ‘<?php the_title(); ?>'”>”<?php the_title(); ?>’‘</h2>’

    this gets the Post time, author and category
    ‘Posted on <?php the_time(‘F jS, Y’) ?> by <?php the_author() ?> in <?php the_category(‘, ‘) ?>’
    finally the loop

    if you want an excerpt to show
    ‘<div class=”entry”>’
    ‘<?php the_excerpt() ?>’

    if you want all content to show

    ‘<?php the_content() ?>’

    you probably have some html divs to close before closing the loop so close them here or else the divs break
    ie ‘</div>’
    & ‘</div>’
    then close the loop-sorry this is older code you can find newer ending loop code in the codex but this should still work
    ‘<?php endwhile; ?>’
    ‘<?php else : ?>’
    ‘<?php endif; ?>’
    then close the main div the one that wraps all the main content on the page:
    then get the footer
    ‘<?php get_footer(); ?>’

    I hope this works out for you.You should definitely read up on the codex and google using wp_blog_header.php in non wordpress page.

    Sorry can’t seem to get the post title code to show.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘trying to use Template tags and the loop’ is closed to new replies.