I’ve the next code registering metabox with kind enter used to enter reside venture hyperlink
operate portfolio_meta_box() {
add_meta_box ('project-meta', 'Add Undertaking Hyperlink', 'portfolio_meta_options', 'portfolio', 'aspect', 'low');
}
add_action("admin_init", "portfolio_meta_box");
operate portfolio_meta_options(){
international $submit;
if ( outlined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
$customized = get_post_custom($post->ID);
$hyperlink = $customized ['project-link'][0];
?>
<enter title="project-link" worth="<?php echo $hyperlink; ?>" />
<?php
}
//save customized meta bins when the submit is saved
operate save_project_link (){
international $submit;
if(outlined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return $post_id;
}
else {
update_post_meta ($post->ID, 'project-link', $_POST['project-link']);
}
}
add_action ('save_post', 'save_project_link');
In my single-portfolio.php I’m utilizing this code to output a venture URL
<?php
get_header(); ?>
<fundamental class="view">
<?php $hyperlink= get_post_custom_values('project-link');
if($hyperlink[0] != "") ://!= not equal empty string
?>
<a href="<?=$hyperlink[0]?>" goal="_blank">view web site</a>
<?php else: ?>
<em>reside hyperlink unavailable</em>
<?php endif; ?>
<?php whereas ( have_posts() ) :the_post(); the_content(); endwhile;?>
</fundamental><!-- .site-main -->
<?php get_footer(); ?>
which provides me the next output (see left column on the screenshot) however I used to be questioning how can I alter the code to present me the output proven in proper column (its a clickable hyperlink which ought to seem below the primary venture screenshot solely)
My second query is I’ve observed in $hyperlink = $customized ['project-link'][0];
and
'<?php $hyperlink= get_post_custom_values('project-link');
if($hyperlink[0] != "") ://!= not equal empty string
?>
<a href="<?=$hyperlink[0]?>" goal="_blank">view web site</a>'
we use [‘project-link’][0]; and $hyperlink[0]. Is the primary one [‘project-link’][0];an listed array with zero index which makes it choose the first worth within the array? as to the second $hyperlink[0] why do we want zero index in that case?