Skip to content

Instantly share code, notes, and snippets.

@andreibabor
Created March 21, 2018 19:40
Show Gist options
  • Save andreibabor/1cc107a88b7f9bf56db12537680b4a1a to your computer and use it in GitHub Desktop.
Save andreibabor/1cc107a88b7f9bf56db12537680b4a1a to your computer and use it in GitHub Desktop.
Wp loop through post and pages
<div id="main-boxes">
<div class="container">
<div class="row">
<?php
$args = array(
'numberposts' => 6,
'post_status'=>"publish",
'post_type'=>"expedition",// was post
'orderby'=>"post_author",
'cat' => 29
);
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<div class="col-lg-4 col-md-6 col-sm-6">
<figure class="gallery-item hvr-grow">
<a href="<?php the_permalink(); ?>">
<?php if(has_post_thumbnail()) { $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'thumbname' );
echo '<span class="img-thumbnail" style="background-image:url(' . $image_src[0] . ')">'; } ?>
<figcaption class="title">
<h5>
<?php if (strlen($post->post_title) > 35) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 35); } else {
the_title();
} ?>
</h5>
</figcaption>
</span>
</a>
</figure>
</div>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
<!-- begin page -->
<?php
$post_id = 10;
$post_url= get_permalink($post_id);
$queried_post = get_post($post_id);
?>
<div class="col-lg-4 col-md-6 col-sm-6">
<figure class="gallery-item hvr-grow">
<a href="<?php echo $post_url; ?>">
<?php
global $post;
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'post');
echo '<span class="img-thumbnail" style="background-image:url(' . $thumb[0] . ')">';
?>
<figcaption class="title">
<h5><?php echo $queried_post->post_title; ?></h5>
</figcaption>
</span>
</a>
</figure>
</div>
<!-- end page -->
</div>
</div>
</div>
@andreibabor
Copy link
Author

modificat linia 8 si pus idul pt pagina la linia 45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment