WordPress.org

Ready to get started?Download WordPress

Forums

unexpected $end (6 posts)

  1. darrlek5000
    Member
    Posted 1 year ago #

    Hi, I'm trying to make a page template that will display a random post while looking like my current theme and I'm not sure where I'm going wrong here, any ideas?

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php
    
    query_posts(array('orderby' => 'rand', 'showposts' => 1));
    
    if (have_posts()) :
    
    while (have_posts()) : the_post(); ?>
    
    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    
    <?php the_content(); ?>
    
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php
    					// If comments are open or we have at least one comment, load up the comment template
    					if ( comments_open() || '0' != get_comments_number() )
    						comments_template( '', true );
    				?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  2. viky081
    Member
    Posted 1 year ago #

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    			<?php
    
    query_posts(array('orderby' => 'rand', 'showposts' => 1));?>
    
    <?php
    if (have_posts()) :
    while (have_posts()) : the_post(); ?>
    
    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    
    <?php the_content(); ?>
    
    				<nav class="nav-single">
    					<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    					<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
    					<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
    				</nav><!-- .nav-single -->
    
    				<?php
    					// If comments are open or we have at least one comment, load up the comment template
    					if ( comments_open() || '0' != get_comments_number() )
    						comments_template( '', true );
    				?>
    
    			<?php endwhile; // end of the loop. ?>
                            <?php endif; //end of the loop.?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Replace this code
    Hope its may help you

  3. darrlek5000
    Member
    Posted 1 year ago #

    Its a big step in the right direction but what i mean is it takes you to the literal post, e.g. you click the random button and it takes you to here http://memehub.net/?p=18 like it opens a random post. like a redirect to a post but without the mass delay, an example of what i mean can be seen here http://www.lulztruck.com/ just press the random button

  4. viky081
    Member
    Posted 1 year ago #

    check this plugin:

    http://wordpress.org/extend/plugins/random-posts-plugin/

    and

    http://rmarsh.com/plugins/post-options/

  5. darrlek5000
    Member
    Posted 1 year ago #

    But like i said before, i dont want a list what i need is it to bring up a random single post

  6. viky081
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.