不应该<?php echo $website_url; ?>
工作
如何调用特定的post meta?所有post\\u meta的正常调用是<?php the_meta(); ?>
, 但如果我只想调用其中的一个特定部分(本例中为website\\uURL),该怎么办?
不应该<?php echo $website_url; ?>
工作
如何调用特定的post meta?所有post\\u meta的正常调用是<?php the_meta(); ?>
, 但如果我只想调用其中的一个特定部分(本例中为website\\uURL),该怎么办?
您可以使用<?=$website_url?>
在公文包模板中,如
<strong>URL: </strong><a href="<?=$website_url?>"><?=$website_url?></a>
让它像follow一样<?php
/*
Template Name: Portfolio
*/
?>
<?php get_header(); ?>
<div id="content">
<?php
$loop = new WP_Query(array(\'post_type\' => \'portfolio\', \'posts_per_page\' => 10));
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$custom = get_post_custom($post->ID);
$screenshot_url = $custom["screenshot_url"][0];
$website_url = $custom["website_url"][0];
?>
<div id="portfolio-item">
<h1><?php the_title(); ?></h1>
<a href="<?=$website_url?>"><?php the_post_thumbnail(); ?> </a>
<strong>URL: </strong><a href="<?=$website_url?>"><?=$website_url?></a>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div><!-- #content -->
<?php get_footer(); ?>
您可以更改位置以匹配您的站姿假设您在循环中:
$website_url = get_post_meta( $post->ID, \'website_url\', true );
在哪里$post->ID
是当前帖子的id。由访问$post
全局或the_ID()
/ get_the_ID()
或者其他方法。