Skip to content

Instantly share code, notes, and snippets.

@tarikcayir
Created August 2, 2015 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarikcayir/e4edf5f5d0d5ed8206d2 to your computer and use it in GitHub Desktop.
Save tarikcayir/e4edf5f5d0d5ed8206d2 to your computer and use it in GitHub Desktop.
WordPress get metabox example
<?php
/**
* The default template for displaying content
*
* Used for both single and index/archive/search.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
// Post thumbnail.
twentyfifteen_post_thumbnail();
?>
<header class="entry-header">
<?php
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
endif;
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php echo 'İlan Tarihi: '. get_post_meta(get_the_ID(), 'ad_date', true); ?><br/>
<?php echo 'İlan Telefonu: '. get_post_meta(get_the_ID(), 'ad_number', true); ?><br/>
<?php echo 'Galeri; '; ?><br/>
<?php $adGallery = get_post_meta(get_the_ID(), 'ad_gallery', false); ?><br/><br/>
<?php /*<pre>
<?php print_r($adGallery); ?>
</pre> */ ?>
<?php foreach ($adGallery as $gallery): ?>
<?php /* <img src="<?php echo $gallery['guid']; ?>" alt="<?php echo $gallery['post_title']; ?>"> */ ?>
<?php $imageSrc = wp_get_attachment_image_src( $gallery['ID'], 'full' ); ?>
<a href="<?=$imageSrc[0]?>" class="fancybox">
<?php echo wp_get_attachment_image( $gallery['ID'], 'adGallery' ); ?>
</a>
<?php //print_r($gallery); ?>
<?php endforeach ?>
<?php
/* translators: %s: Name of current post */
the_content( sprintf(
__( 'Continue reading %s', 'twentyfifteen' ),
the_title( '<span class="screen-reader-text">', '</span>', false )
) );
wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
'separator' => '<span class="screen-reader-text">, </span>',
) );
?>
</div><!-- .entry-content -->
<?php
// Author bio.
if ( is_single() && get_the_author_meta( 'description' ) ) :
get_template_part( 'author-bio' );
endif;
?>
<footer class="entry-footer">
<?php twentyfifteen_entry_meta(); ?>
<?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment