WordPress WPML php language condition
1 2 3 4 5 |
<?php if(ICL_LANGUAGE_CODE=='en'){ ?> <?php }else if(ICL_LANGUAGE_CODE=='fr'){ ?> <?php } ?> |
1 2 3 4 5 |
<?php if(ICL_LANGUAGE_CODE=='en'){ ?> <?php }else if(ICL_LANGUAGE_CODE=='fr'){ ?> <?php } ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
//global $wp_query; $today = date("Y-m-d"); $args_widget = array( 'post_type' => 'tribe_events', 'eventDisplay' => 'all', 'meta_query' => array( array( 'key' => '_EventEndDate', 'value' => $today, 'compare' => '>=', ) ), 'tax_query' => array( array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => 'activites-permanentes', ) ), 'orderby' => 'rand', 'posts_per_page' => -1 ); $loop_widget = new WP_Query($args_widget); echo' <div class="tribe-mini-calendar-wrapper"> <div class="tribe-mini-calendar-list-wrapper"> <div class="tribe-events-loop hfeed vcalendar">'; while ( $loop_widget->have_posts() ) : $loop_widget->the_post(); endwhile;</div> </div> </div> |
Order of category and post come from “Intuitive Custom Post Order” plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<section id="section_album_photo" class="fw-main-row "> <div class="fw-main-row-bg" style=" "></div> <div class="fw-main-row-overlay has-color"></div> <div style="" class="fw-container "> <div class="fw-row"> <div class="fw-col-xs-12 "> <div class="textblock-shortcode"><h2><?php echo $cat->name; ?></h2></div> </div> </div> <?php $args = array( 'post_type' => 'galerie_photo', 'cat' => $cat->term_id, 'posts_per_page' => -1, ); $counter = 1; $loop = new WP_Query( $args ); $count_loop = $loop->post_count; while ( $loop->have_posts() ) : $loop->the_post(); //$photo_id = get_the_id(); $image = get_field('galerie_image'); ?> <?php if ($counter == 1) { ?> <div class="fw-row"> <?php } ?> <div class="fw-col-xs-12 fw-col-sm-3 "> <div class="textblock-shortcode"> <?php if( get_field('galerie_credits') ){ $galerie_credits = '<small align="center">Photo par '.get_field('galerie_credits').'</small>'; }else{ $galerie_credits = ''; } ?> <?php if( get_field('galerie_web_uniquement') == 1) { $galerie_web_uniquement = '<small align="center">web uniquement</small>'; }else{ $galerie_web_uniquement = ''; } ?> <?php if( get_field('galerie_titre_visible') ){ echo "<h3>".get_field('galerie_titre_visible')."</h3>"; } ?> <?php echo do_shortcode( '[restrict userlevel="subscriber"] <a href="'.$image["url"].'" rel="attachment wp-att-3974" target="_blank"> [/restrict]' ); ?> <img src="<?php echo $image['sizes']['thumbnail']; ?>" width="150" height="150" class="alignnone size-thumbnail"> <?php echo do_shortcode( '[restrict userlevel="subscriber"] </a>'.$galerie_credits.''.$galerie_web_uniquement.'[/restrict]' ); ?> </div> </div> <?php //echo $wp_query->post_count; if (($counter % 4 == 0) && ($counter != $count_loop)){ ?> </div> <div class="fw-row"> <div class="fw-col-xs-12 "> <div class="fw-divider-space" style="padding-top: 50px;"></div> </div> </div> <div class="fw-row"> <?php } $counter +=1; ?> <?php endwhile; ?> </div> </div> </section> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
function my_mce4_options($init) { $default_colours = '"000000", "Black", "993300", "Burnt orange", "333300", "Dark olive", "003300", "Dark green", "003366", "Dark azure", "000080", "Navy Blue", "333399", "Indigo", "333333", "Very dark gray", "800000", "Maroon", "FF6600", "Orange", "808000", "Olive", "008000", "Green", "008080", "Teal", "0000FF", "Blue", "666699", "Grayish blue", "808080", "Gray", "FF0000", "Red", "FF9900", "Amber", "99CC00", "Yellow green", "339966", "Sea green", "33CCCC", "Turquoise", "3366FF", "Royal blue", "800080", "Purple", "999999", "Medium gray", "FF00FF", "Magenta", "FFCC00", "Gold", "FFFF00", "Yellow", "00FF00", "Lime", "00FFFF", "Aqua", "00CCFF", "Sky blue", "993366", "Red violet", "FFFFFF", "White", "FF99CC", "Pink", "FFCC99", "Peach", "FFFF99", "Light yellow", "CCFFCC", "Pale green", "CCFFFF", "Pale cyan", "99CCFF", "Light sky blue", "CC99FF", "Plum"'; $custom_colours = '"E14D43", "Color 1 Name", "D83131", "Color 2 Name", "ED1C24", "Color 3 Name", "F99B1C", "Color 4 Name", "50B848", "Color 5 Name", "00A859", "Color 6 Name", "00AAE7", "Color 7 Name", "282828", "Color 8 Name"'; // build colour grid default+custom colors $init['textcolor_map'] = '['.$default_colours.','.$custom_colours.']'; // enable 6th row for custom colours in grid $init['textcolor_rows'] = 6; return $init; } add_filter('tiny_mce_before_init', 'my_mce4_options'); |
Visual Composer
1 2 3 4 |
$id=972; $post = get_post($id); $content = apply_filters('the_content', $post->post_content); echo $content; |
No Visual Composer
1 2 3 4 |
$id=972; $post = get_post($id); $content = apply_filters('the_content', $post->post_content); echo $post->post_content; |
Basic Page Content
1 2 3 4 |
$the_query = new WP_Query( 'page_id=972' ); while ($the_query -> have_posts()) : $the_query -> the_post(); the_content(); endwhile; |
1 |
add_filter('sanitize_file_name', 'remove_accents' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
global $post; $time = date ('m/d/Y'); // Set up custom query with meta_query to compare event start date with today's date $args = array ( 'post_type' => 'event', // your event post type slug 'post_status' => 'publish', // only show published events 'orderby' => 'meta_value', // order by date 'meta_key' => 'event_start_date', // your ACF Date & Time Picker field 'meta_value' => $time, // Use the current time from above 'meta_compare' => '>=', // Compare today's datetime with our event datetime 'order' => 'ASC', // Show earlier events first 'posts_per_page' => 10, ); // The Query $listings = new WP_Query(); // The Loop $listings->query($args); if($listings->found_posts > 0) { echo '<ul>'; while ($listings->have_posts()) { $listings->the_post(); $id = $post->ID; //echo $id; $newDate = date_i18n(get_option('date_format'), strtotime(get_post_meta($id, 'event_start_date', true))); //$event_data = get_post_meta($id); //print_r($event_data); if(get_post_meta($id, 'event_start_date', true)){ $listItem = '<li>'; $listItem .= '<a href="' . get_permalink() . '">'; $listItem .= get_the_title() . '</a>'; $listItem .= '<br><span> ' . $newDate . '</span></li>'; $listItem .= '</li>'; echo $listItem; } } echo '</ul>'; wp_reset_postdata(); } else { // no posts found echo '<p style="padding:25px;">Aucun événement</p>'; } |
1 2 3 4 5 6 7 8 9 10 11 |
function change_menu($items, $args){ if(!is_front_page()){ if ($args->theme_location == 'main_navigation') { foreach($items as $item){ $item->url = get_bloginfo("url") . "/" . $item->url; } } } return $items; } add_filter('wp_nav_menu_objects', 'change_menu', 10, 2); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
function wpb_mce_buttons_2($buttons) { array_unshift($buttons, 'styleselect'); return $buttons; } add_filter('mce_buttons_2', 'wpb_mce_buttons_2'); /* * Callback function to filter the MCE settings */ function my_mce_before_init_insert_formats( $init_array ) { // Define the style_formats array $style_formats = array( // Each array child is a format with it's own settings array( 'title' => 'Content Block', 'inline' => 'span', 'classes' => 'text_vc_title_black', 'wrapper' => true, ), array( 'title' => 'Blue Button', 'inline' => 'span', 'classes' => 'text_vc_title_orange', 'wrapper' => true, ) ); // Insert the array, JSON ENCODED, into 'style_formats' $init_array['style_formats'] = json_encode( $style_formats ); return $init_array; } // Attach callback to 'tiny_mce_before_init' add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function change_menu($items){ if(!is_front_page()){ foreach($items as $item){ $item->url = get_bloginfo("url") . "/" . $item->url; } } return $items; } add_filter('wp_nav_menu_objects', 'change_menu'); |