This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function my_endpoint( $request_data ) { | |
| // setup query argument | |
| $args = array( | |
| 'post_type' => 'my_post_type', | |
| ); | |
| // get posts | |
| $posts = get_posts($args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add ACF Columns | |
| function add_new_events_column($columns) { | |
| $columns['event_date'] = 'Event Date'; | |
| return $columns; | |
| } | |
| add_filter('manage_events_posts_columns', 'add_new_events_column'); | |
| function add_new_events_admin_column_show_value( $column, $post_id ) { | |
| if ($column == 'event_date') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- competitions countdown with post type "competição" --> | |
| <?php | |
| //If the event is happening | |
| $args = array( | |
| 'post_type' => 'competicao', | |
| 'meta_query' => [ | |
| 'relation' => 'AND', | |
| [ | |
| 'key' => 'date_picker', | |
| 'compare' => '<=', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // check parent repeater | |
| if( have_rows('parent_navigation_items', 'options') ): | |
| echo '<ul class="nav primary-header-nav">'; | |
| // loop parent items | |
| while ( have_rows('parent_navigation_items', 'options') ) : the_row(); | |
| echo '<li>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function my_post_guidelines() { | |
| $screen = get_current_screen(); | |
| if ( 'post' != $screen->post_type ) | |
| return; | |
| $args = array( | |
| 'id' => 'my_website_guide', | |
| 'title' => 'Content Guidelines', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function set_featured_image_from_gallery() { | |
| global $post; | |
| $post_id = $post->ID; | |
| $has_thumbnail = get_the_post_thumbnail($post_id); | |
| if ( !$has_thumbnail ) { | |
| $images = get_field('image_gallery', $post_id, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // http://php.net/manual/en/function.date.php | |
| //get the time from the ACF time picker see php.net for date formats | |
| $printdate = DateTime::createFromFormat('Ymd', get_post_meta($post->ID, 'event_date', 'true')); //event_date from custom feild | |
| $eventDate = $printdate->format('m/d/Y'); | |
| if (time() < strtotime("$eventDate 11:59PM")) { ?> | |
| <!-- the date has not passed SHOW CONTENT --> | |
| <?php } else { ?> | |
| <!-- SORRY the date has passed already--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //check for refering page to switch content based on referrer | |
| $referrer = $_SERVER['HTTP_REFERER']; | |
| if ($referrer == 'http://url.com' or $referrer == 'http://url-2.com') { | |
| //Matches YES! | |
| } else { | |
| //Matches NO! | |
| header( 'Location: http://www.url.com/no-soup-for-you/' ) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Excerpt with formating from WYSIWYG | |
| function improved_trim_excerpt($text) { | |
| global $post; | |
| if ( '' == $text ) { | |
| $text = get_the_content(''); | |
| $text = apply_filters('the_content', $text); | |
| $text = str_replace('\]\]\>', ']]>', $text); | |
| $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); | |
| //$text = strip_tags($text, '<p>'); | |
| $excerpt_length = 70; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h1> | |
| <?php if (is_singular('your_cpt') || is_archive('your_cpt') || is_post_type_archive('your_cpt') ) { ?> | |
| YOUR CPT NAME | |
| <?php } elseif (is_search()) { ?> | |
| Search | |
| <?php } elseif (is_404()) { ?> | |
| Error 404 | |
| <?php } else { ?> | |
| <?php the_field('headline_text'); ?> | |
| <?php } ?> |