Support » Fixing WordPress » Need help coding next random post

  • Hi all,

    Currently my website is http://www.kieshetsnel.nl/random and as you can see on the posts there is an Arrow left and on the right of the screen. At the moment i’ve done this with the plugin WP Post Navigation, but when you can make the same thing with just coding it’s fine by me.

    When i press the button on the right (next page) i go to the next page by order, but i want to go to a random page so it somehow needs to included the link http://www.kieshtsnel.nl/random

    What code can I use and can recommend me?

    Regards

Viewing 1 replies (of 1 total)
  • You will have to make changes to your code files. I dont think a plugin will help and is needed anyways.

    But am unclear as to what your permalinks are like;
    and what is say for example this – http://www.kieshetsnel.nl/selena-gomez-taylor-swift/.
    Basically, is it a post or a page?

    I assume you are using Sydney theme?

    So, if its a post, you will need to edit content-single.php:

    <div class="entry-content">
    <?php the_content(); ?>
    <?php wp_link_pages( array('before' => '<div class="page-links">' . __('Pages:', 'sydney'),	'after'  => '</div>', ) ); ?>
    </div><!-- .entry-content -->

    insert a <a href="http://www.kieshtsnel.nl/random">Next &rsaquo;&rsaquo;</a> before <?php the_content(); ?> and check.

    and if its a page, edit content-page.php, where you will find the same code snippet, and you need to make similar changes.

    if its a custom posttype then we will have to look at it likewise.

    Pls edit with care, possibly on child theme and take backups.

    Am curious to know how you got the redirects done from http://www.kieshtsnel.nl/random to a random post. whats the htaccess hack? would be glad to know the code. 🙂

    Cheers…

Viewing 1 replies (of 1 total)
  • The topic ‘Need help coding next random post’ is closed to new replies.