This file contains 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 | |
add_filter('request', 'hwk_post_type_toplevel_request', 1, 1); | |
function hwk_post_type_toplevel_request($query){ | |
$post_type = 'portfolio'; | |
if(isset($query[$post_type]) && isset($query['post_type']) && $query['post_type'] === 'portfolio') | |
return $query; |
This file contains 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 | |
function get_field_from_block($post_id, $block_name, $field_name){ | |
$block_name = 'acf/' . $block_name; | |
$post = get_post($post_id); | |
if ( has_blocks( $post->post_content ) ) { | |
$blocks = parse_blocks( $post->post_content ); | |
foreach ($blocks as $block){ | |
if ($block['attrs']['name'] == $block_name){ | |
$data = $block['attrs']['data'][$field_name]; | |
break; |
This file contains 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 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 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 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 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 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); |