wamslers
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Get result from two post_types by post_metaThank you – it works! This is my code:
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $today2 = date('Ymd', strtotime('-6 hours')); $myquery = new WP_Query(array('post_type' => array('elements','calendar'), 'posts_per_page' => 6, 'paged' => $paged, 'orderby' => 'title', 'order' => 'ASC', 'meta_query'=>array( 'relation'=>'AND', array( 'key' => 'from_date', 'value' => $today2, 'compare' => '<=', 'type' => 'CHAR' ), array( 'key' => 'to_date', 'value' => $today2, 'compare' => '>=', 'type' => 'CHAR' ) ) )); if ($myquery->have_posts()) : while ($myquery->have_posts()) : $myquery->the_post(); $posttype = get_post_type(get_the_ID()); if($posttype == 'elements'){ $calendar_color = 'followup'; } else { $calendar_type = get_post_meta(get_the_ID(), 'type', TRUE); if($calendar_type == 1){ $calendar_color = 'vacation'; }elseif($calendar_type == 2){ $calendar_color = 'dayoff'; }elseif($calendar_type == 3){ $calendar_color = 'meeting'; } } ?> <div class="calendar-box-<?=$calendar_color?>"><?=the_title();?> | <?=$calendar_color?></div> <?php endwhile; wp_reset_postdata(); else : endif; ?>
- This reply was modified 6 years, 9 months ago by wamslers.
When I change the last line in the function
return apply_filters( 'get_calendar', $calendar_output );
to justreturn $calendar_output;
some of my javascripts dosen’t work.– i think it’s going wrong in the bottom, where I add_filter or apply_filters!
Forum: Developing with WordPress
In reply to: Using while and foreach with $wpdbIt works now when I use
get_results
instead ofresults
Forum: Developing with WordPress
In reply to: Using while and foreach with $wpdbI’m creazy – yes, it make sense to change the parameters in the foreach – but it still dosen’t work ??
<?php $records=$wpdb->results("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'"); $all = array(); foreach($records as $data): $all[]=$data; // doing stuff endforeach; return $all; ?>
I think my SELECT statement is wrong. When I use a manual mysqli connection it works with a non-wordpress-tabel. I have the global
$wpdb;
just behind theget_header();
Forum: Developing with WordPress
In reply to: Using while and foreach with $wpdb@diondesigns
But how can I determine the mysql extension?Now I have tried to combine the two loops – but I get no results from the database.
<? get_header(); global $wpdb; ?>
…..
<?php $records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'"); $all = array(); foreach($data as $records): $all[]=$data; ?> <li data-id="<?php echo $data['id']; ?>" class="ui-state-default"> <span class="ui-icon ui-icon-arrowthick-2-n-s"></span> <?php echo $data['id']; ?> <?php echo $data['name']; ?> <?php echo $data['post_title']; ?> </li> <?php endforeach; return $all; ?>
- This reply was modified 6 years, 10 months ago by wamslers.
Forum: Fixing WordPress
In reply to: show who currently editing a post in wordpress frontendI do it myself – here is my php code. Maybe not the right way – but it’s work for me:
date_default_timezone_set("UTC"); // Setting the timezone $the_current_time = time()."UTC:"; // Get the current time $post_lock = get_post_meta(get_the_ID(), '_edit_lock', TRUE); // Get the value from the post_meta field for lock and revision $ret = explode(':', $post_lock); // Explode the value (timestamp:user_ID) if($the_current_time-15 <= $ret[0]) { $css_lock_color = 'red'; } else { $css_lock_color = $css_color; } // Make an if statement for the css class
- This reply was modified 6 years, 10 months ago by wamslers.
Forum: Fixing WordPress
In reply to: show who currently editing a post in wordpress frontend@hardeepasrani I am using ACF – Advanced Custom Fields for the edit-forms in backend.
@diondesigns Okay – I try to make an DB-based session function – but I just think that the WP admin already shows who is editing, it have to be possible to get the information also for the frontend (the frontend will be a user-registred area).
Forum: Fixing WordPress
In reply to: meta_query don't work on WP_Query – it's shows all postsThank You @jesper van Engelen – it works.
Forum: Hacks
In reply to: get meta value using get_result