WordPress.org

Ready to get started?Download WordPress

Forums

Link to random post, pointing to my local installation?! (1 post)

  1. lilblogger
    Member
    Posted 2 years ago #

    On my site muchzen.com I'm using the following code to make a link that takes you to a random post:

    <?php
    $randomPost = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
    echo '<a href="'.$randomPost.'">Next &rarr;</a>'; ?>

    It works on my local installation on my computer, but when I upload the theme to muchzen.com, it retrieves a random post with an URL on my computer installation instead of the WordPress site online.

    How do I fix this?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.