dynamically retrieving a single post from the url variable
-
I am using WP as a CMS for a DJ site. He will have a Videos page with a list of videos. I have defined a Videos category for posts that have the code to display each movie. The Video page displays the most recent video and then has a list of links to the older videos. The links are in the form of “/video.php?p=12” I’d like for a person to be able to click the link, the page refreshes or goes to a video2.php page or popup that shows that video and the list of other videos. I added code to Request the variable ‘p’ from the url. that works. But I can’t insert that value into the query string to pull a certain post from the database. The query works if I use
<?php query_posts('p=13');?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?><br />
<?php the_content(); ?>
<?php endwhile;?>But doesn’t if I try
<?php $video = $_REQUEST['p']; echo $video; $page = "'p=".$video."'";?>
<?php query_posts("'p=".$video."'");?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?><br />
<?php the_content(); ?>
<?php endwhile;?>or
<?php $video = $_REQUEST['p']; echo $video; $page = "'p=".$video."'";?>
<?php query_posts($page);?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?><br />
<?php the_content(); ?>
<?php endwhile;?>Is there a way to get a single post dynamically based on the url without using a template system? I tried the get single post plugin but it didn’t work for me and wouldn’t be dynamic either.
- The topic ‘dynamically retrieving a single post from the url variable’ is closed to new replies.