lundi 26 janvier 2015

How to display wordpress custom post type with custom fields?


Vote count:

0




I have this custom post type with custom fields. I am trying to display the content side by side:


(left) image and then (right) content. And hopefully all custom posts follow along the same way.


This is my code:



<?php
/*
Template Name: Bares
*/
?>
<?php get_header(); ?>
<?php include 'headyinside.php';?>

<div class="container">






<div class="col-md-8">

<?php query_posts( 'post_type=bares'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></a></h1>
<!-- abre imagem-->
<p> <?php
$image = get_field('imagemquadradabar');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?> </p>
<!--fecha imagem-->

<?php the_content(); ?>
<p><strong> Review: </strong> <?php the_field('descricaobar'); ?> </p>
<p><strong> Morada: </strong> <?php the_field('moradabar'); ?> </p>

<hr />

<?php endwhile; else: ?>
<h2>Woops...</h2>
<p>Sorry, no posts we're found.</p>
<?php endif; ?></ul>
<p align="center"><?php posts_nav_link(); ?></p>

</div>



<div class="col-md-4">
<?php get_sidebar(); ?>
</div>
</div>



<?php get_footer(); ?>


Tried each and every solution I find online, but so far nothing works for me.


I know I am missing something, but reached a dead end for my limited knowledge.


Thank you!



asked 2 mins ago







How to display wordpress custom post type with custom fields?

Aucun commentaire:

Enregistrer un commentaire