Support » Plugin: Nice Portfolio » Adding Fields to the Project

  • Resolved kaitlynjanine

    (@kaitlynjanine)


    Hi! So far I love your plugin. I had to search very hard to find an extendable portfolio plugin with category filtering. I needed additional fields for my portfolio. I have successfully added them to the meta box using my child theme’s functions.php file. I am having trouble getting them to show up in the project page or the portfolio page, though. There are a lot of hooks and filters and I’m a little rusty with WordPress. Can you please give me a little more guidance? Which functions do I need to override?

Viewing 2 replies - 1 through 2 (of 2 total)
  • As much as I wanted to do this purely using overrides, I just decided to use the ACF plugin and grab the fields with the usual WordPress syntax within my theme overrides. I really appreciate the flexibility of your plugin!! Definitely the only one that suits my needs. Thanks!

    Plugin Author Andrés Villarreal

    (@andrezrv)

    Hi kaitlynjanine!

    I’m really sorry for the delayed response, I hope you still find this useful.

    You don’t necessarily have to override a function. This plugin works with a complete template system that you can make use of. Let’s suppose you added a new field doing something like this:

    
    add_filter( 'nice_portfolio_metabox_info_fields', 'my_portfolio_metabox_info_fields' );
    
    function my_portfolio_metabox_info_fields( $fields ) {
    	$fields[] = array(
    		'type'  => 'text',
    		'label' => esc_html__( 'My Awesome Field', 'my-textdomain' ),
    		'name'  => '_project_awesome_field',
    		'desc'  => esc_html__( 'My awesome field description', 'my-textdomain' ),
    	);
    
    	return $fields;
    }
    

    In this example, the _project_awesome_field key will be the internal identifier for the new field once the data is saved. So we can retrieve and print the value using get_post_meta() like this:

    
    <?php echo get_post_meta( get_the_ID(), '_project_awesome_field', true ); ?>
    

    The best place to include something like this is inside a custom template. The plugin includes a lot of templates that can you can override from your theme to include this kind of implementations. You can take a look at the templates folder inside the plugin to choose the one that better suits your needs, and then create a new template in your theme to override that one. Inside each template file you’ll find the path where you need to put your custom template.

    You can even create a completely new template inside your theme and call it where you need it by using the nice_portfolio_get_template() function. There’s a lot of examples on how to use this function inside the public/template-loaders.php file.

    Sorry again for the time it took to answer your question. Please let us know if we can be of any help with this issue.

    Best,

    Andrés.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding Fields to the Project’ is closed to new replies.