Ultimate WP Query Search Filter
https://wordpress.org/plugins/ultimate-wp-query-search-filter/
Category Archives: WordPress plug-in
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.
- Get tags used only by custom post type links.
- Only output name of the tag if it has a post attached to it.
- 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:
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' ); }
If language then else if
Display depending on language
<?php if ( ICL_LANGUAGE_CODE == 'en' ) { ?> <h1>English headline</h1> <?php } else if (ICL_LANGUAGE_CODE == 'da') { ?> <h1>Danish headline</h1> <?php } ?>
With shortcode: https://wpml.org/forums/topic/if-icl_language_codeit/
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
Add language code to body
Language code added as ID.
<body id="lang-<?php echo ICL_LANGUAGE_CODE; ?>">
Ouput:
<body id="lang-en">
Resource: https://wpml.org/forums/topic/how-to-add-class-to-body-tag-language/
Custom Types field and WooCommerce
Add it to functions.php
add_action('woocommerce_single_product_summary', 'jvo_product_data', 22 ); function jvo_product_data() { echo "<div class='jvo-product-data'>"; echo types_render_field("jvo-product-data", array("output"=>"HTML")); echo "</div>"; }
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 }?>
HTML inside PHP
Only display HTML if custom field type excist.
<?php echo "<p>".types_render_field("jvo-testimonial-post-service-type", array("output"=>"HTML")); echo "</p>" ?>