开发者

WordPress: Separating the content of a post into multiple pages and linking to them

I have a custom post type in a WordPress theme called "reviews." On the template "single-reviews.php" there is some text, then a table full of specs, then a gallery, etc. I want to put the specs table and gallery each on a separate page. The specs and gallery would still have to somehow get the data for that开发者_如何学Python review, though. Links to these sub-pages would be at the top of the review page.

I'm thinking that somehow a variable needs to get passed from the single review page to the specs page or the gallery page when a user clicks on either of those. My research isn't showing me a good way to do this, though. I think being inside of WP makes it more of a challenge.

My question is, is this possible, and has anybody done it before? If I can't get this to work, then I will use JavaScript to show/hide sections when they are clicked on.


You can still write PHP code in your templates, it doesn't have to be WordPress specific. Stick something in the URL and use $_GET['something'] to decide what section of the post to display.

<a href="?display=gallery">Gallery</a> <a href="?display=specs">Specs</a>

<?php if (isset($_GET['display'] && $_GET['display'] == "gallery"): ?>
    Gallery HTML
<?php endif; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜