Support » Plugins » Hacks » get a post from a new template page

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    The combination of query vars resulting from both a race and calendar request results in a query that cannot return anything, hence the 404. If the URL must be of that format, use the Rewrite API to inform WP how to properly parse the URL in order to return the correct post.

    If the URL format is not needed to be of that form, you could achieve the results you desire by altering the stats page to use simple calendar URLs, then altering the single-calendar.php template to display the stat field. If the stat field is not always appropriate, the template can contain a conditional statement to only show the field when appropriate.

    I change my item url to this:

    And in my template i put this in the start:

    $parametro = $_GET[‘stat’];

    Them you can get the url param, date1

    You can use this param in the whole template and build your filter, for example:

    $args = array(
    	'posts_per_page' => 1,
    	'post_type'      => 'calendario',
    	'name'           => $parametro,
    	'post_status'    => 'publish'
    $the_query = new WP_Query( $args );
    <?php // THE LOOP ?> 
    <? } else { ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get a post from a new template page’ is closed to new replies.