Skip to main content
Better title and code formatting
Source Link
t31os
  • 18.7k
  • 3
  • 56
  • 68

Need help for Custom Post Typen and images How can i link a custom post type thumbnail to intermediate size

Code: Custom-post-type-template ----Custom post type template

    <?php
    /*    /*   
    Template Name: test Post Type Gallery    
*/
    get_header();  
?>
            <div id="container">
    <div id="content" role="main">
         
  <div id="content" role="main">
    <?php $loop = new WP_Query( array( 'post_type' => 'bird', 'posts_per_page' => 10 ) ); ?>
        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
             
        <ul class="gallery-ul">
                        <li class="the-picture"><?php the_title( '<h2 class="picture-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
                        <a href="-----?????????--------"> <?php the_post_thumbnail(array(200,200)); ?></a></li>
        </ul>
         
    </ul>
    <?php endwhile; ?>
             
    </div><!-- #content -->
            </div><!-- #container -->
 
    <?php get_sidebar(); ?>
    <?php get_footer(); ?> 

    

Functions.phpFunctions.php
This is for the Size of the Images

Need help for Custom Post Typen and images

Code: Custom-post-type-template ----

    <?php
        /*      Template Name: test Post Type Gallery   */
    get_header(); ?>
            <div id="container">
                <div id="content" role="main">
    <?php $loop = new WP_Query( array( 'post_type' => 'bird', 'posts_per_page' => 10 ) ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                    <ul class="gallery-ul">
                        <li class="the-picture"><?php the_title( '<h2 class="picture-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
                        <a href="-----?????????--------"> <?php the_post_thumbnail(array(200,200)); ?></a></li>
                    </ul>
    <?php endwhile; ?>
                </div><!-- #content -->
            </div><!-- #container -->
 
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

Functions.php
This is for the Size of the Images

How can i link a custom post type thumbnail to intermediate size

Custom post type template

<?php
/*       
    Template Name: test Post Type Gallery    
*/
get_header();  
?>
<div id="container">
    <div id="content" role="main">
         
        <?php $loop = new WP_Query( array( 'post_type' => 'bird', 'posts_per_page' => 10 ) ); ?>
        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
         
        <ul class="gallery-ul">
            <li class="the-picture"><?php the_title( '<h2 class="picture-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
            <a href="-----?????????--------"> <?php the_post_thumbnail(array(200,200)); ?></a></li>
        </ul>
         
        <?php endwhile; ?>
         
    </div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?> 

    

Functions.php
This is for the Size of the Images

Functions.php --- This
This is for the Size of the Images

if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size

if ( function_exists( 'add_theme_support' ) ) { 
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails
    add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size
    add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size
}
    

Functions.php --- This is for the Size of the Images

if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size

Functions.php
This is for the Size of the Images

if ( function_exists( 'add_theme_support' ) ) { 
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails
    add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size
    add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size
}
    
Source Link
user3422
user3422

Need help for Custom Post Typen and images

I'm trying to build a picture gallery with custom post type in my theme and I think i figure it out almost everything but the call in the template, I already have the custom post type in the functions.php, I have a Page with a custom call to the post type and it’s working (the post are showing in the page with the template) what I cannot figure it out it’s the call for the href that should go to open the image bigger probably with some modal like lightbox or something like that.

I have to mention that I’m trying to use feature image and already have created some image sizes for it in the functions.php, I’m going to paste the code for you to understand… Thank you in advance

Code: Custom-post-type-template ----

    <?php
        /*      Template Name: test Post Type Gallery   */
    get_header(); ?>
            <div id="container">
                <div id="content" role="main">
    <?php $loop = new WP_Query( array( 'post_type' => 'bird', 'posts_per_page' => 10 ) ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
                    <ul class="gallery-ul">
                        <li class="the-picture"><?php the_title( '<h2 class="picture-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
                        <a href="-----?????????--------"> <?php the_post_thumbnail(array(200,200)); ?></a></li>
                    </ul>
    <?php endwhile; ?>
                </div><!-- #content -->
            </div><!-- #container -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

Functions.php --- This is for the Size of the Images

if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size