Types: checkbox

When using Types to show multiple checkbox content.

<?php if(types_render_field('kontaktopl', array('raw'=>'true'))){?>
<?php echo '<p class="freelance-jobmeta-type">Kontaktoplysninger:</p><p class="freelance-jobmeta-data">'.types_render_field("kontaktopl", array("output"=>"HTML","separator"=>"<br>")); ?></p>
<?php }?>

Display posts by tags

Display posts only with a tag, and sort alphabetical first by tag and then by post.

  1. Get tags used only by custom post type links.
  2. Only output name of the tag if it has a post attached to it.
  3. For each tag name output all the posts (title and special field type notes).
<?php
        $tags = get_tags();
        foreach ( $tags as $tag )
            {
            $tag_query = new WP_Query( array(
                'post_type' => array('links'),
                'tag_id' => $tag->term_id,
                'posts_per_page' => -1,
                'orderby' => 'title',
                'order' => 'ASC',
                'no_found_rows' => true,
                ) );
            if( $tag_query->have_posts() )
                {
                    echo '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">';
                        echo '<h3>' .$tag->name. '</h3>';
                    echo '</div><!-- .col -->';
                }
        while ( $tag_query->have_posts() ) : $tag_query->the_post(); ?>
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"><!-- link -->
                <a href="<?php echo types_render_field("links-url", array("output"=>"raw")); ?>">
                    <p><?php the_title(); ?>
                        <?php if(types_render_field('links-notes', array('raw'=>'true'))){ ?>
                            <span>(<?php echo types_render_field("links-notes", array("output"=>"HTML")); ?>)</span>
                    <?php } ?>
                    </p>
                </a>
            </div><!-- .col -->
             <?php endwhile; } ?>
<?php wp_reset_postdata(); ?>

The output result:

display-posts-by-tags_2016-02-20_13.22.43

Disable plugin CSS

If, a plugin is linking to external/loading CSS, do the following.

In the plugin folder search for “wp_enqueue_style”. The first parameter is the function name.

wp_enqueue_style( 'tablepress-default'

In funtions.php add:

/**
 * Disable style sheet
 */
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
    wp_deregister_style( 'tablepress-default' );
}

Limit characters

50 refers to the maximum number of characters.

/* limit characters */
add_action( 'woocommerce_after_shop_loop_item_title', 'lk_woocommerce_product_excerpt', 25);
if (!function_exists('woocommerce_template_single_excerpt'))
{
function lk_woocommerce_product_excerpt()
{
$content_length = 10;
global $post;
$content = $post->post_excerpt;
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) :
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content = force_balance_tags($content);
$content = substr($content, 0, 50);
endif;
echo "<div class='archive-excerpt'><p>$content<span>...</span></p></div>";
}
}

Resource: http://stackoverflow.com/questions/23063730/woocommerce-product-description-length-characters

Types: empty field

If custom field type is empty or has a value.

If “varighed” has a value, display. Otherwise don’t. Code snippet #1

<?php if(types_render_field('varighed', array('raw'=>'true'))){?>
<?php echo '<p class="freelance-jobmeta-type">Varighed:</p><p class="freelance-jobmeta-data">'.types_render_field("varighed", array("output"=>"HTML")); ?></p>
<?php }?>

Code snippet #2

<?php if(types_render_field('fw_product_wine_appellation', array('raw'=>'true'))){?>
<dt class="productLabel"><?php echo __( 'Appellation:', 'formulawino' ); ?></dt><dd class="productDescription"><?php echo(types_render_field('fw_product_wine_appellation', array('class'=>''))); ?></dd>
<?php }?>

If value display

<?php if(types_render_field('methods-tools-download-box-form', array('raw'=>'true'))){?>
<div class="methodsToolsFree"><?php echo "Free download included"; ?></div><?php }?>