Skip to main content

call posts by calling custom post types

<?php

    $lastposts = get_posts( array(
        'posts_per_page' => 5 ,
        'post_type'   => 'projects'
    ) );

    if ( $lastposts ) {
        foreach ( $lastposts as $post ) :
            setup_postdata( $post ); ?>

                <div class="portfolio-panel" style="background: url(' <?php the_post_thumbnail_url(); ?>')">
                    <div class="panel-clickthroughs">
                        <a class="company-logo-link">
                        <?$logo_image = get_field('logo_image');?>
                        <img class="company-logo" src="<? echo $logo_image['url'];?>" alt="">
                        </a>
                        <a class="button-link" href="<?php the_permalink(); ?>">
                            <button>View</button>
                        </a>
                    </div>
                </div>

    <?php
    endforeach;
    wp_reset_postdata();
}
?>

Comments

Popular posts from this blog

add custom post type

/**  *  * add custom post type  *  */ function my_custom_post_product() {   $labels = array(     'name'               => _x( 'Products', 'post type general name' ),     'singular_name'      => _x( 'Product', 'post type singular name' ),     'add_new'            => _x( 'Add New', 'book' ),     'add_new_item'       => __( 'Add New Product' ),     'edit_item'          => __( 'Edit Product' ),     'new_item'           => __( 'New Product' ),     'all_items'          => __( 'All Products' ),     'vi...

Toolset conditional

[wpv- if evaluate= "'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']' OR '[wpv-current-user info='role']' = 'administrator'" ]      //the content you want to hide goes here [/wpv- if ]