Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

dadako on "generate single pages based on custom meta?"

$
0
0

I'm trying to be as conservative as possible with my posts in a new wordpress site and let custom meta generate content across the site.

One of my custom meta tags is "video", in it I place a link to a youtube video that relates to the article.

The articles can be in one of three categories. Some don't have video so I query that up front.

As a result I can generate a category called "video", this page just lists any post with the "video" custom meta:

<?php
$recentPosts = new WP_Query();
$recentPosts->query('cat=1,2,3');
while ($recentPosts->have_posts()) :
$recentPosts->the_post();
?>
<?php if (get_post_meta($post->ID, "video", true)) : ?>
<a href="<?php the_permalink(); ?>"><?php the_title(''); ?></a>
<?php endif;?>
<?php endwhile; ?>

Clicking on the resulting link here will take a user to the post containing the video, so far so good. The post will be displayed in it's relevant category template.

However what I'd like to achieve is that when the link is clicked, the user is taken to an entirely new single-post template that displays the video meta data & title, but in it's own post format regardless of the category the post is in (not the category template).

Really not sure where to start, other than making separate posts for videos in their own category, which would be doubling up of data.

Any advice very welcome.


Viewing all articles
Browse latest Browse all 8245

Trending Articles