Forum Replies Created

Viewing 15 replies - 46 through 60 (of 141 total)
  • 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 3 years, 10 months ago by wyclef.
    • This reply was modified 3 years, 10 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?

    Thread Starter wyclef

    (@wyclef)

    Thanks for confirming @palmerct this describes the situation precisely.

    Thread Starter wyclef

    (@wyclef)

    Thanks for this info! I wasn’t aware of the Pro version.

    Thread Starter wyclef

    (@wyclef)

    Good to know. Thanks. They seem to be someone minimal in use in what I am working on but I will definitely keep this in mind moving forward and try to address it as I go.

    Thread Starter wyclef

    (@wyclef)

    Thanks for the info. I just ended up needing a simple add action line.

    Thread Starter wyclef

    (@wyclef)

    I see. Let me expand upon this code a bit to see if you might be able to shed some more light on what is going on here. The first chunk of code is from an older build and works, the second chunk is from a newer build and does not work, specifically in regard to the metajs /admin/init.js portion. I realize, more context would probably be better, however this is an isolated issue where I can copy the jq_scripts chunk of code from the working one, into the one that isn’t working, and then my problem is solved but am trying to understand what they were trying to do by taking it out in the first place, and how to possibly solve it more simply. Not sure if this is entirely doable without more understanding of the what’s and the why’s but figure I’d put this out here for starters. Thanks for your time.

    works

    if (is_admin() ){
    	function admin_scripts(){	
    		wp_register_script('metajs', INDEX_JS .'/admin/init.js', array('jquery','media-upload','thickbox'));
    		wp_enqueue_script('metajs');
    	}
    }
    
    if(!is_admin()) {
    	add_action('wp_enqueue_scripts', 'jq_scripts');
    }
    		function jq_scripts(){	
    		   wp_deregister_script('jquery');
    		   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", false);
    		   wp_enqueue_script('jquery');
    		}
    
    add_action('admin_enqueue_scripts', 'admin_scripts');

    Not Working

    if (is_admin() ){
    	function admin_scripts(){	
    		wp_register_script('metajs', INDEX_JS .'/admin/init.js', array('jquery','media-upload','thickbox'));
    		wp_enqueue_script('metajs');
    	}
    }
    
    	if (!is_admin() ){
    		function front_scripts(){		
    		
    		    global $smof_data, $theme_options;
    			$theme_data = wp_get_theme();
    			wp_enqueue_script('jquery');
    			
    				  
    	        wp_register_script('Init', INDEX_JS. '/init.js' ,array('jquery'),  TRUE);		
    			wp_register_script('QueryLoader', INDEX_JS .'/jquery.queryloader2.js', array('jquery'),  true);	
    			wp_register_script('scripts', INDEX_JS .'/scripts.js', array('jquery'),  true);	
    			wp_register_script('shortcodes', INDEX_JS .'/shortcodes.js', array('jquery'),  true);	
    										
        		wp_enqueue_script('QueryLoader');
        		wp_enqueue_script('Init');	
    			wp_enqueue_script('scripts');
    			wp_enqueue_script('shortcodes');
    				   		
    
    	}
      add_action('wp_footer', 'front_scripts');
    • This reply was modified 4 years ago by wyclef.
Viewing 15 replies - 46 through 60 (of 141 total)