• So I’ve got my portfolio page (with images defined by html (by css is possible if needed)). And now I ‘add’ portfolio information pages by just making a new page, and then putting the link of that page in the href of the according image on my portfolio home page.

    Is there a way I can (by using CPT):
    – Add an image on the portfolio page
    – Add an new portfolio information page (with an custom template (I am now just manually selecting the template when I make a portfolio information page).
    – Automatically insert the url of the portfolio information page on that image (on the portfolio page).

    Or is this not possible?

    (for better understanding I have already obtained this by doing it manually on my site (you can click on the images and then be taken to the portfolio information page), I would like to do this by using CPT …

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    A CPT does not afford you any extra possibilities, it only allows you to logically organize certain types of data. As far as WP is concerned, it is still handled like any other page or post, the custom type simply serves as a label.

    However, you can write code that only does certain things when that CPT is involved. You cannot do anything you cannot do for any other post, but you can cause what you do to occur only for that type.

    Your main portfolio page needs to run a standard loop. It is essentially a portfolio archive page. Based on the query run, all information pages you create will be automatically listed on that page.

    One thing a CPT affords is it is listed separately in the admin menu, so when you add a new one, the template page for that CPT is used by default. In fact, you have to try hard to apply a different template. You can add images to this post type just as you would do for normal posts.

    Even though CPTs do not allow you any special properties, it makes sense for you to use it precisely for the organizational purposes it was intended. It is setup to do pretty much what you want.

    Thread Starter Bensji

    (@bensji)

    Ok, I think I understand! I need to make the CPT, and then make an archive-{CPT}.php as my portfolio ‘home’ page?

    ps: Thanks for the reply!

    Moderator bcworkz

    (@bcworkz)

    You’re welcome!

    You sort of have it but not quite. You do need an archive-{post_type}.php template to handle CPT archive requests. You probably can also set this as your home page in the settings, though I’m not 100% sure. You may need to make page based on the same template and set that as the home page.

    You might also need a single-{post_type}.php to handle requests for individual information pages, unless the default single.php works for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post type’ is closed to new replies.