I am creating a social bookmarking site using WordPress.

I am using a custom field to store the web URL. Then when a user clicks the Title, it redirects to the original blog post page.

Please check this one: http://popurls.com/ (I am creating a site like this one).

I don't need blog posts because I want to save the Title, one Custom Field to save the URL, Category and Tag only. But in WordPress, there is a blank page created automatically, and even blog description is null.

So when a user submits a URL, one page is automatically created.

Is there way to redirect all blog post pages to Home page (only blog POST pages, not normal pages)?


3 Answers 3


Myself found the answer.

I added <?php wp_redirect( 'http://www.mydomainname.com', 301 ); exit; ?> in single.php page.


Doable, I think, if you're ready to custom code a loop which will modify the post titles' link urls.

With a custom field called title_link, your code could end up looking something like this:

<?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>"> <!-- post -->
        <?php $titleLink = get_post_meta($post->ID, 'title_link', true); ?>
        <h1><a href="<?php echo $titleLink; ?>"><?php the_title(); ?></a></h1>
        <?php the_content(); ?>
    </div> <!-- /post -->
<?php endwhile; ?>

Credit to this guy here.


You want to redirect all those pages which have a post type "post", to redirect all those pages we will write this in the first line before even html tag:

if((get_post_type( get_the_ID() ) == 'post' ) && !is_home() ) 
  header("Location: " . home_url());

Explanation: get_post_type( get_the_ID() )checks whether the current page being displayed is post, we also need to check whether the page is home page or not through is_home() otherwise we will get a redirect loop error.

  • Add that in header.php
    – Faizan Ali
    Oct 22, 2014 at 12:17
  • Add that to your answer (not as a comment). Also explain why this should help solving the problem presented in the question.
    – kaiser
    Oct 22, 2014 at 12:18
  • 1
    Answer modified with the better explanation and even the code has been tried myself too :) Thanks for the guidance!!!
    – Faizan Ali
    Oct 22, 2014 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.