Okay
  Public Ticket #600876
Portfolio - meta data
Closed

Comments

  • Bryan started the conversation

    The meta data displays all the time, is there a way to change the code so that it will not display if the content is NULL?

    At the same time if you want to use the custom meta data to insert an Address for example it eliminates the functionality of the Website field so that this links properly.


  •  291
    Paul replied

    Hi there!

    1. You can edit the output of the meta data in \"/uxb_templates/single-portfolio.php\" file.

    2. I will check this and update it in the next version. Thanks for your feedback!

    Regards,
    Paul

  •  291
    Paul replied

    Regarding the 2.) about the custom field that is a link, please try this:

    1. Open \"/uxb_templates/single-portfolio.php\" file.

    2. Find this code:

    foreach ( $custom_set as $item ) {
                                    
                                    $meta_unique_id = UXB_PORT_CUSTOM_META_ID_INITIAL . uxb_port_clean_string_for_id( $item[\'uxb_port_po_custom_meta_info_id\'] );
                                    $custom_meta_title = $item[\'title\'];
                                    ?>
                                    <li><strong class=\"title\"><?php echo esc_html( $custom_meta_title ); ?></strong><?php echo uxb_port_get_portfolio_meta_text( get_post_meta( get_the_ID(), $meta_unique_id, true ) ); ?></li>
                                    <?php
                                    
                                }

    3. Edit it to:

    foreach ( $custom_set as $item ) {
                                    
                                    $meta_unique_id = UXB_PORT_CUSTOM_META_ID_INITIAL . uxb_port_clean_string_for_id( $item[\'uxb_port_po_custom_meta_info_id\'] );
                                    $custom_meta_title = $item[\'title\'];
                                    ?>
                                    
                                    <?php
                                        // The Regular Expression filter
                                        $reg_exUrl = \"/(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/\";
    
    
                                        // The Text you want to filter for urls
                                        $text = uxb_port_get_portfolio_meta_text( get_post_meta( get_the_ID(), $meta_unique_id, true ) );
    
    
                                        // Check if there is a url in the text
                                        if(preg_match($reg_exUrl, $text, $url)) {
                                                
                                                $to_be_replaced = array( \'http://\', \'https://\' ); 
                                                
                                               // make the urls hyper links
                                               $text = preg_replace($reg_exUrl, \'<a href=\"\'.$url[0].\'\" target=\"_blank\">\'.str_replace( $to_be_replaced, \'\', $url[0] ).\'</a>\', $text);
                                                
                                        }
                                        
                                        ?>
                                    
                                    
                                    <li><strong class=\"title\"><?php echo esc_html( $custom_meta_title ); ?></strong><?php echo $text; ?></li>
                                    <?php
                                    
                                }

    This should make the link text works properly.

    NOTE: Make sure that the link text has \"http://\" at the front.

  • Bryan replied

    I have updated this and it is still displaying NULL values.

    Please see my site, and the item linked:

    http://dev.westcapmgt.ca/portfolio/forge-oil-gas-ltd/

  •  291
    Paul replied

    Hi,

    The code that I gave you in the previous reply is for making any URL text (eg. http://uxbarn.com) of the custom meta field linkable, not about hiding the empty fields. In other words, it means that if you enter \"http://uxbarn.com\" into any meta info field, it will display as a link instead of a normal text.

    In case you want to hide any empty fields instead of showing as \"-\", you would need to manually edit the code in the \"/uxb_templates/single-portfolio.php\" file.

    Regards,
    Paul