Answer the question
In order to leave comments, you need to log in
How to embed php into php?
Hello!
There is a page with the output of records from wp
<?php
/**
* The default template for displaying content
*
* Used for masonry blog
*
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('post-in-blog '); ?>>
<div class="post-masonry"> <a href="<?php the_permalink(); ?>" >
<!-- <?php if (has_post_thumbnail() && !post_password_required() && !is_attachment()) : ?>
<div class="entry-thumbnail">
<a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail('mp-emmet-thumb-medium-masonry'); ?></a>
</div>
<?php endif; ?> -->
<header class="entry-header">
<h2 class="entry-title h5">
<?php echo (get_post_meta($post->ID, 'sq', true)); ?>
</h2>
</header>
<section class="entry-content">
<p>
<?php
echo (get_post_meta($post->ID, 'etazh', true));
?>
</p>
</section>
<footer class="entry-footer">
<div class="meta">
<span class="date-post h6"><?php echo (get_post_meta($post->ID, 'class', true)); ?></span>
<?php if (comments_open()) : ?>
<a class="comments-count" href="<?php if(!is_single()):the_permalink(); endif; ?>#comments" >
<span class="fa fa-comments-o"></span><span><?php comments_number(' 0', ' 1', ' %'); ?></span>
</a>
<?php endif; ?>
<div class="clearfix"></div>
</div>
</footer>
</a> </div>
</article>
<!-- #post -->
Answer the question
In order to leave comments, you need to log in
Good day.
Apparently this code should be in any cycle where posts are displayed.
Read: https://codex.wordpress.org/The_Loop
Did it like this:
<?php
/*
* portfolio section
*/
?>
<div class="container main-container">
<div class="row clearfix">
<div class=" masonry-blog masonry">
<?php $query = new WP_Query('content-masonry'); ?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('post-in-blog '); ?>>
<div class="post-masonry"> <a href="<?php the_permalink(); ?>" >
<header class="entry-header">
<h2 class="entry-title h5">
<?php echo (get_post_meta($post->ID, 'sq', true)); ?>
</h2>
</header>
<section class="entry-content">
<p>
<?php
echo (get_post_meta($post->ID, 'etazh', true));
?>
</p>
</section>
<footer class="entry-footer">
<div class="meta">
<span class="date-post h6"><?php echo (get_post_meta($post->ID, 'class', true)); ?></span>
<div class="clearfix"></div>
</div>
</footer>
</a> </div>
</article>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question