Created
March 21, 2018 19:40
-
-
Save andreibabor/1cc107a88b7f9bf56db12537680b4a1a to your computer and use it in GitHub Desktop.
Wp loop through post and pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modificat linia 8 si pus idul pt pagina la linia 45