WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] show full posts on php website - not working! any expert there? (4 posts)

  1. Brianffm
    Member
    Posted 1 year ago #

    Hi,
    I'm trying to make the wordpress content show up in my website via php:
    <?php
    require('./blog/wp-blog-header.php'); ?>

    I can only manage to make the sidebar show up with:
    <?php get_sidebar();?>

    but the rest is never visible and I don't know why. I thought it would be easy like: "get content"! But it's not working with my code.
    I am using a modified twentyeleven theme here is my code:

    <?php
    require('./blog/wp-blog-header.php'); ?>

    <div id="content" role="main">

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

    <div class="entry">
    <?php the_content(); ?>
    </div>

    <p class="postmetadata"><?php the_tags('Tags: ', ', ', '
    '); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    </div>
    <?php endwhile; endif; ?>

    </div><!-- #content -->
    <?php get_sidebar();?>

  2. Andrew Bartel
    Member
    Posted 1 year ago #

    It is easy in WordPress. But here ya go: http://davidwalsh.name/wordpress-recent-posts

  3. Brianffm
    Member
    Posted 1 year ago #

    Thank you so much!
    It did not work exactly as on david walsh's website, but I found it a bit differently here: http://codex.wordpress.org/Template_Tags/get_posts

    Now I only can't seem to get the "leave reply", comment section on my page and the tags! is that not possible or do I need to add something else?

    here is the code as it works right now, in case someone else needs it:

    <?php
    require('./blog/wp-blog-header.php'); ?>

    <div id="primary" class="site-content">
    <div id="content" role="main">

    <?php
    $args = array();
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <h3>"><?php the_title(); ?></h3>
    <?php the_content(); ?>
    <?php the_content(); ?>
    <?php endforeach; ?>

    </div><!-- #content -->
    </div><!-- #primary -->

    <?php get_sidebar();?>

  4. Brianffm
    Member
    Posted 1 year ago #

    Phew! I got it!
    Had to modify the text from single.php in the theme folder. It now shows the whole content exactly like it does on the blog.
    I just had to add a div and 40px margin, so it wouldn't start on the very left.
    here is the code:

    <?php
    require('./blog/wp-blog-header.php'); ?>
    
    <div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php
    $args = array();
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
    
    <?php endforeach; ?>
      <div class="entry-meta"> </div>
    		</div><!-- #content -->
    	</div><!-- #primary -->
        <?php get_comments(); ?>
    
    </div>
    <?php get_sidebar();?>

    [Please post code between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags