• Resolved Quin

    (@quin452)


    ((I posted this on the regular WordPress support as well… four hours prior))

    Normally, I use WordPress Categories/Posts to do my portfolio, but I want to give Jetpack a chance.

    Now, what I normally do is create the structure to display the post, and then fill it out with the API. However, I do not know how to call the values for a Project.

    This is the structure which I want to populate:

    <section id="portfolio" class="section group">
        <article class="col span_1_of_4">
            <h2>Recent Work</h2>
            <p>Latest portfolio piece here, to be accompanied by three, yes <strong>three</strong> images.</p>
            <p>I have no idea how it will work for coding pieces; perhaps I could show the end results?  I've always got to include a snippet of the code, you know, rotated a slight bit.</p>
            <p>Oh wait, I need to have some <a href="">hyperlinks</a> every now and then to see what <a href="">it looks like</a>.  What do you think? <a href="">Good</a>, <a href="">Bad</a>?</p>
        </article>
    
        <aside class="col span_1_of_4">
            <img src="" alt="hey look, this is the code" />
        </aside>
    
        <article class="col span_1_of_4">
            <img src="" alt="somehow show the code working" />
        </article>
    
        <aside class="col span_1_of_4">
            <img src="" alt="not a clue what to include here though" />
        </aside>
    </section>

    So the H2 will be the title, followed by the content/excerpt, and then I want three images – this will not be the thumbnail, but I was thinking of custom fields, except Portfolio doesn’t support them; any way to solve this?

    https://wordpress.org/plugins/jetpack/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Do the 3 images refer to 3 different projects in your portfolio, or do you plan on creating that page, listing a bit of content and 3 images, for each project in your portfolio?

    I was thinking of custom fields, except Portfolio doesn’t support them

    You can use add_post_type_support to add custom fields support to Jetpack’s Portfolios:
    https://codex.wordpress.org/Function_Reference/add_post_type_support

    To do so, you’d need to add the following to a functionality plugin:

    add_action('init', 'jetpackme_add_cf_support_portfolio');
    function jetpackme_add_cf_support_portfolio() {
        add_post_type_support( 'jetpack_portfolio', 'custom-fields' );
    }
    Thread Starter Quin

    (@quin452)

    I plan on listing the title, the content/excerpt and three images associated with the latest Project.

    So

    Title
    Content | Image 1 | Image 2 | Image 3

    If the function you’ve provided works, it will all that I need 🙂 I cannot test it ATM.

    Thread Starter Quin

    (@quin452)

    Hi Jeremy, I’ve added it to my functions.php, and the fields aren’t added.
    (I’m using a custom child theme, so I can edit the functions page without worry of updates)

    Also, how would I get the_title, etc., from a Portfolio Project?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    the fields aren’t added

    You won’t see any new field. You will, however, see the custom fields box below the visual editor, and you’ll be able to add your custom fields there.
    If you don’t see the box, I’d suggest clicking on “Screen Options” at the top of the page, and activating the custom fields there.

    how would I get the_title, etc., from a Portfolio Project?

    Portfolio projects are just another post type, so you can use core WordPress functions to get the title, content, … Have a look at how the loop is built in your theme, and use the same structure. You should see things like the_title, the_content, …

    Thread Starter Quin

    (@quin452)

    Yea, I meant that it wasn’t in the Screen Options. It is not below the visual editor, and there is not an option to enable them.

    It is there for regular pages/posts.

    Also, I’m using the following for getting posts:

    <?php
    	global $post;
    	$latestposts = get_posts('numberposts=1');
    	foreach($latestposts as $post) :
    ?>
    <article class="col span_1_of_2">
    	<h2><?php the_title(); ?></h2>
    	<?php the_post_thumbnail('full'); ?>
    	<?php the_excerpt(); ?>
    
    	<aside>
    		<a href="<?php echo esc_url(get_permalink()); ?>" class="slim">Read More</a>
    	</aside>
    </article>
    <?php endforeach; ?>

    How could I modify that for Projects?

    Thread Starter Quin

    (@quin452)

    UPDATE: I’ve switched out the code using while (have_posts()) : the_post(); and a query filtering for post_type. Works fine now.

    Still cannot get the Screen Options to work.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I’m sorry, that was my fault. I used an underscore instead of a dash in the portfolio post type name. Try this:

    add_action('init', 'jetpackme_add_cf_support_portfolio');
    function jetpackme_add_cf_support_portfolio() {
        add_post_type_support( 'jetpack-portfolio', 'custom-fields' );
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Portfolio Project Values and Custom Fields’ is closed to new replies.