WordPress.org

Ready to get started?Download WordPress

Forums

alternative single.php (2 posts)

  1. fedai47
    Member
    Posted 1 year ago #

    Hi,

    if
    url=http://domain.com/post-title/abc
    mysingle.php

    else (url=http://domain.com/post-title/)
    single.php

    Is this possible?

  2. coopersita
    Member
    Posted 1 year ago #

    I once did something like that, but I was loading a page dedicated to those types of posts:

    url=http://domain.com/custom-page/abc=yes&pid=890
    mysingle.php

    else (url=http://domain.com/post-title/)
    single.php

    I was putting the post id as a variables into the urls, along with a variable to check if the page should load the current template or not. In my custom template I had this:

    if($_GET['abc']=="no"){
       $permalink = get_permalink( $_GET['pid'] );//Load the page normal
       header( 'Location: '.$permalink ) ;
      }
       if(!isset($_GET['pid'])){
       $permalink = get_bloginfo('url');//no PID was set, so go to home
       header( 'Location: '.$permalink ) ;
      }
      $pid= $_GET['pid'];

    Then, I had a custom loop that took the pid to load the content of that post.

    query_posts('p='.$pid.'&limit=1');
    if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    It may not work for you, since you want the post title in the url, but maybe you can add a variable to the url, like I did, and put the code in the single.php, to send you to your custom template...

    There may be an easier way to do it, but that's just how I did it for my project.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.