Forum Replies Created

Viewing 15 replies - 46 through 60 (of 146 total)
  • Thread Starter wyclef

    (@wyclef)

    I see. The calendar date would be based on a date entered via a custom date field in WP post.

    Thread Starter wyclef

    (@wyclef)

    @darkog are there any updates on any of this?

    Thread Starter wyclef

    (@wyclef)

    Right. I think I might try to hook this class outside of the image tag via the body class or something else where I may be able to avoid even needing this class on the image tag. If that doesn’t work guess I’ll just roll with the if statement.

    Thread Starter wyclef

    (@wyclef)

    I am not sure if this is a problem anymore. It may have just been a one time thing.

    Thread Starter wyclef

    (@wyclef)

    Wondering if there is any progress on this?

    Thread Starter wyclef

    (@wyclef)

    Yea, seems like I might need an if statement. This is only on one page I think, how would I hook it to a specific page? Like, I would just put the if statement with the two different returns?

    Thread Starter wyclef

    (@wyclef)

    Perfect. Thanks! Relying on $showCounter is very simple.

    Thread Starter wyclef

    (@wyclef)

    Ok, I think we were on the right track I was maybe just looking at the wrong if statement. Got this to work does it look alright? Nevermind, only seems to show the else now regardless if upcoming post is published.

    // Display Events
    function getLandingEvents() {
      global $post;
      $eventsArray = array();
      $dateArray = array();
      $counter = 0;
      $postHTML = '<div class="events-list">';
      $args = array('category_name' => 'events');
      query_posts($args);
      if ( have_posts() ) : while ( have_posts() ) : the_post();
              $dateArray[] = array('date' => get_field('date', $post->ID), 'pid' => $post->ID);
              $counter++;
            endwhile;
      endif;
    
      foreach ($dateArray as $key => $row) {
          $dateTemp[$key]  = $row['date'];
          $pidTemp[$key] = $row['pid'];
      }
    
      array_multisort($dateTemp, SORT_ASC, $pidTemp, SORT_ASC, $dateArray);
    
      $today = date('Ymd');
      $showCounter = 0;
      for ($i = 0; $i < count($dateArray); $i++) {
        $currentDay = new DateTime($today);
        $eventDate = new DateTime($dateArray[$i]['date']);
        $interval = $currentDay->diff($eventDate);
    
        if (($interval->format('%R') == '+') && ($interval->format('%a') <= 60) && $showCounter < 3) {
            $categories = get_the_category($dateArray[$i]['pid']);
            $slug = trim($categories[0]->slug);
            if (get_field('date', $dateArray[$i]['pid']) != '') {
              $date = DateTime::createFromFormat('Ymd', get_field('date', $dateArray[$i]['pid']));
              $mainDate = $date->format('M dS');
              $month = $date->format('n');
              $day = $date->format('j');
              $simpleDate = $date->format('Y-m-d');
            }
    
            $postHTML .= '<div class="event">';
            $postHTML .= '<a href="'.get_permalink($dateArray[$i]['pid']).'">';
            $postHTML .= '<time datetime="'.$simpleDate.'">'.$month.'/'.$day.'</time>';
            $postHTML .= '<div class="text-holder">';
            if ($categories[0]->parent != 0) {
              $childCatName = trim($categories[0]->name);
              $postHTML .= '<h2>'.$childCatName.'</h2>';
            }
            $postHTML .= '<p><strong>'.get_the_title($dateArray[$i]['pid']).'</strong></p>';
            $postHTML .= '<h3>'.get_field('event-subheading', $dateArray[$i]['pid']).'</h3>';
            $postHTML .= '<div class="info">';
            $postHTML .= '<p>Thursday, <time datetime="'.$simpleDate.'">'.$mainDate.', '.get_field('time', $dateArray[$i]['pid']).'</time></p>';
            if (get_field('location', $dateArray[$i]['pid']) != '') {
                $postHTML .= '<p>'.get_field('location', $dateArray[$i]['pid']).'</p>';
            }
            $postHTML .= '</div>';
            $postHTML .= '</div>';
            $postHTML .= '</a>';
            $postHTML .= '</div>';
            $showCounter++;
        }
          else {
                $postHTML .= '<div class="event"><div class="text-holder"><h3>Check back soon for next semester’s events!</h3></div></div>';
                break;
            }
    
      }
      $postHTML .= '</div>';
    
      return $postHTML;
    }
    • This reply was modified 4 years, 11 months ago by wyclef.
    • This reply was modified 4 years, 11 months ago by wyclef.
    Thread Starter wyclef

    (@wyclef)

    Hmmm, not getting anything. Not breaking anything, just not showing the return. Do I have this return correct?

    // Display Events
    function getLandingEvents() {
      global $post;
      $eventsArray = array();
      $dateArray = array();
      $counter = 0;
      $postHTML = '<div class="events-list">';
      $args = array('category_name' => 'events');
      query_posts($args);
      if ( have_posts() ) : while ( have_posts() ) : the_post();
              $dateArray[] = array('date' => get_field('date', $post->ID), 'pid' => $post->ID);
              $counter++; 
            endwhile;
            else :
                return '<h3>Check back soon for next semester’s events!</h3>';
      endif;
    
      foreach ($dateArray as $key => $row) {
          $dateTemp[$key]  = $row['date'];
          $pidTemp[$key] = $row['pid'];
      }
    
      array_multisort($dateTemp, SORT_ASC, $pidTemp, SORT_ASC, $dateArray);
    
      $today = date('Ymd');
      $showCounter = 0;
      for ($i = 0; $i < count($dateArray); $i++) {
        $currentDay = new DateTime($today);
        $eventDate = new DateTime($dateArray[$i]['date']);
        $interval = $currentDay->diff($eventDate);
    
        if (($interval->format('%R') == '+') && ($interval->format('%a') <= 60) && $showCounter < 3) {
            $categories = get_the_category($dateArray[$i]['pid']);
            $slug = trim($categories[0]->slug);
            if (get_field('date', $dateArray[$i]['pid']) != '') {
              $date = DateTime::createFromFormat('Ymd', get_field('date', $dateArray[$i]['pid']));
              $mainDate = $date->format('M dS');
              $month = $date->format('n');
              $day = $date->format('j');
              $simpleDate = $date->format('Y-m-d');
            }
    
            $postHTML .= '<div class="event">';
            $postHTML .= '<a href="'.get_permalink($dateArray[$i]['pid']).'">';
            $postHTML .= '<time datetime="'.$simpleDate.'">'.$month.'/'.$day.'</time>';
            $postHTML .= '<div class="text-holder">';
            if ($categories[0]->parent != 0) {
              $childCatName = trim($categories[0]->name);
              $postHTML .= '<h2>'.$childCatName.'</h2>';
            }
            $postHTML .= '<p><strong>'.get_the_title($dateArray[$i]['pid']).'</strong></p>';
            $postHTML .= '<h3>'.get_field('event-subheading', $dateArray[$i]['pid']).'</h3>';
            $postHTML .= '<div class="info">';
            $postHTML .= '<p>Thursday, <time datetime="'.$simpleDate.'">'.$mainDate.', '.get_field('time', $dateArray[$i]['pid']).'</time></p>';
            if (get_field('location', $dateArray[$i]['pid']) != '') {
                $postHTML .= '<p>'.get_field('location', $dateArray[$i]['pid']).'</p>';
            }
            $postHTML .= '</div>';
            $postHTML .= '</div>';
            $postHTML .= '</a>';
            $postHTML .= '</div>';
            $showCounter++;
        }
      }
      $postHTML .= '</div>';
    
      return $postHTML;
    }
    Thread Starter wyclef

    (@wyclef)

    Thanks for your reply. Does this look right to you, it doesn’t seem to do anything.

    // Display Events
    function getLandingEvents() {
      global $post;
      $eventsArray = array();
      $dateArray = array();
      $counter = 0;
      $postHTML = '<div class="events-list">';
      $args = array('category_name' => 'events');
      query_posts($args);
      if ( have_posts() ) : while ( have_posts() ) : the_post();
              $dateArray[] = array('date' => get_field('date', $post->ID), 'pid' => $post->ID);
              $counter++;
            endwhile;
            else :
        $postHTML .= '<h3>Check back soon for next semester’s events!</h3>';
      endif;
    
      foreach ($dateArray as $key => $row) {
          $dateTemp[$key]  = $row['date'];
          $pidTemp[$key] = $row['pid'];
      }
    
      array_multisort($dateTemp, SORT_ASC, $pidTemp, SORT_ASC, $dateArray);
    
      $today = date('Ymd');
      $showCounter = 0;
      for ($i = 0; $i < count($dateArray); $i++) {
        $currentDay = new DateTime($today);
        $eventDate = new DateTime($dateArray[$i]['date']);
        $interval = $currentDay->diff($eventDate);
    
        if (($interval->format('%R') == '+') && ($interval->format('%a') <= 60) && $showCounter < 3) {
            $categories = get_the_category($dateArray[$i]['pid']);
            $slug = trim($categories[0]->slug);
            if (get_field('date', $dateArray[$i]['pid']) != '') {
              $date = DateTime::createFromFormat('Ymd', get_field('date', $dateArray[$i]['pid']));
              $mainDate = $date->format('M dS');
              $month = $date->format('n');
              $day = $date->format('j');
              $simpleDate = $date->format('Y-m-d');
            }
    
            $postHTML .= '<div class="event">';
            $postHTML .= '<a href="'.get_permalink($dateArray[$i]['pid']).'">';
            $postHTML .= '<time datetime="'.$simpleDate.'">'.$month.'/'.$day.'</time>';
            $postHTML .= '<div class="text-holder">';
            if ($categories[0]->parent != 0) {
              $childCatName = trim($categories[0]->name);
              $postHTML .= '<h2>'.$childCatName.'</h2>';
            }
            $postHTML .= '<p><strong>'.get_the_title($dateArray[$i]['pid']).'</strong></p>';
            $postHTML .= '<h3>'.get_field('event-subheading', $dateArray[$i]['pid']).'</h3>';
            $postHTML .= '<div class="info">';
            $postHTML .= '<p>Thursday, <time datetime="'.$simpleDate.'">'.$mainDate.', '.get_field('time', $dateArray[$i]['pid']).'</time></p>';
            if (get_field('location', $dateArray[$i]['pid']) != '') {
                $postHTML .= '<p>'.get_field('location', $dateArray[$i]['pid']).'</p>';
            }
            $postHTML .= '</div>';
            $postHTML .= '</div>';
            $postHTML .= '</a>';
            $postHTML .= '</div>';
            $showCounter++;
        }
      }
      $postHTML .= '</div>';
    
      return $postHTML;
    }
    Thread Starter wyclef

    (@wyclef)

    Never mind, just had the count and count++ mixed up here is the working code.

    function pastLectures() {
        $args = array('order' => 'DESC');
        $posttags = get_tags($args);
        $count = 0;
        $tags = '';
        $tags .= '<ul>';
        if ($posttags) {
            foreach($posttags as $tag) {
                //print_r($tag);
                $tempYear = substr($tag->slug, 0, 4);
                $pastLecturesYes = get_field('add-to-past-lecture-series', 'post_tag_'.$tag->term_id);
                if ($pastLecturesYes[0] == 'add') {
                    $count++;
                    $tagLink = get_tag_link($tag->term_id);
                    $tags .= '<li><a href="'.$tagLink.'"> '.$tag->name.'</a></li>';
                    if( $count > 4 ) break;
                }
    
            }
        }
        $tags .= '</ul>';
        return $tags;
    }
    Thread Starter wyclef

    (@wyclef)

    Trying to just limit the count to 5 on the working chunk of code. Thinking I am just missing something simple here.

    Thread Starter wyclef

    (@wyclef)

    @darkog emailed you my diagnostic information.

    Thread Starter wyclef

    (@wyclef)

    Yes

    Thread Starter wyclef

    (@wyclef)

    could deactivating IP Geo Block and not uninstalling cause a conflict here?

Viewing 15 replies - 46 through 60 (of 146 total)