WordPress.org

Ready to get started?Download WordPress

Forums

Read more post help (5 posts)

  1. Roggers
    Member
    Posted 1 year ago #

    Hey guys! I recently created a portfolio CPT (my first ever Custom Post type) for my WordPress theme. Like many portfolio's mine has a grid based layout, with each section having the post's featured image and an excerpt of the text.

    However, when I want the text to display the full post (by clicking 'more') I get a link to the whole featured image, not the post.

    The link has the following code
    <a title="<?=$title?>: <?=$desc?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>">(more)</a>

    I'm pretty sure i need to change the:

    portfolio_thumbnail_url($post->ID)

    But I'm not sure what to?

    This is probably quite easy, but I'm a beginner with php and wordpress, as I said it's my first Custom Post type.

    Thanks a lot!

    Roggers.

  2. zex2911
    Member
    Posted 1 year ago #

    try changing

    <?php print portfolio_thumbnail_url($post->ID); ?>

    to

    <?php the_permalink(); ?>
  3. Roggers
    Member
    Posted 1 year ago #

    I told you it's simple! Thanks It worked.

    One thing though, If i wanted to place the image (which was set as a featued image for CPT, as an example for the portfolio) On the permalink page, how would I do it?

  4. zex2911
    Member
    Posted 1 year ago #

    You just have to call that image with something like this (this is from my portfolio page)

    <?php if (has_post_thumbnail($post->ID))
    	the_post_thumbnail( 'thumbnail' );
    	else
    	echo '<img src="' . bloginfo( 'template_url' ) . '/images/mix-of-sites.png" alt="picture" />';
    ?>

    That code checks does your post have featured image
    - if yes, display thumbnail size of it
    - if not, display 'mix-of-sites.png' from images folder
    That code is inside the loop of my portfolio-page.php, which is set up to display only portfolio items.
    Hope that makes sense. :)

  5. Roggers
    Member
    Posted 1 year ago #

    Wow, sorry for late reply.

    I think there might be an issue with that snippet. It prints my images url as text instead of into the html.

    Also should i put it in page.php, or single.php? As that's where my portfolio defaults to once you click an item.

Topic Closed

This topic has been closed to new replies.

About this Topic