Skip to content

Commit

Permalink
Merge pull request #2192 from CityOfPhiladelphia/fix-homepage-calls
Browse files Browse the repository at this point in the history
Fix homepage & the latest calls
  • Loading branch information
karissademi authored Oct 3, 2024
2 parents f1e1db8 + 239ac4d commit 193cf76
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 49 deletions.
26 changes: 13 additions & 13 deletions wp/wp-content/themes/phila.gov-theme/partials/posts/post-grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@
*
*/
?>
<?php
<?php
$override = rwmb_meta('phila_get_post_cats');
$override_url = isset($override['override_url']) ? $override['override_url'] : '';
$post_categories = isset($category) ? $category : '';
$override_url = isset($override['override_url']) ? $override['override_url'] : '';
$is_tag = isset($is_spotlight_tag) ? $is_spotlight_tag : rwmb_meta('phila_get_post_cats');
$tag = isset($is_tag['tag']) ? $is_tag['tag'] : $a['tag'];

if (!is_page_template('templates/the-latest.php') ) {
$is_tag = isset($is_spotlight_tag) ? $is_spotlight_tag : rwmb_meta('phila_get_post_cats');
$tag = isset($is_tag['tag']) ? $is_tag['tag'] : $a['tag'];

}

?>
<?php if (!empty($post_categories)): ?>
<?php foreach ($post_categories as $category ) {
$current_cat = get_category($category);
$slang_name = urlencode(html_entity_decode(trim( phila_get_owner_typography( $current_cat ))));
} ?>
<?php else: ?>
<?php
<?php
$current_cat = null;
$slang_name = '';
?>
<?php endif; ?>
<?php

<?php

/* if categories aren't set, this is the latest. */
if ( empty( $post_categories ) ) {
Expand Down Expand Up @@ -58,7 +63,7 @@
$sticky_posts = new WP_Query( $sticky_args );
// set_transient( get_the_ID().'_sticky_posts_results', $sticky_posts, 1 * HOUR_IN_SECONDS );
}


}

Expand Down Expand Up @@ -140,10 +145,6 @@
'value' => 'english',
'compare' => '=',
),
array(
'key' => 'phila_select_language',
'compare' => 'NOT EXISTS'
),
),
)
);
Expand All @@ -157,7 +158,6 @@
$result = new WP_Query();
// set_transient( get_the_ID().'_empty_posts_results', $result, 1 * HOUR_IN_SECONDS );
}

//if sticky posts is empty, don't add it to the results array
$result->posts = array_merge(isset($sticky_posts->posts) ? $sticky_posts->posts : array(), $more_posts->posts);

Expand Down Expand Up @@ -236,7 +236,7 @@
$see_all_URL = array(
'URL' => '/the-latest/archives/?tag=' . $term,
);
else:
else:
$term = get_term($tag, 'post_tag');
$see_all_URL = array(
'URL' => '/the-latest/archives/?tag=' . $term->name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
<?php
//Don't execute this code if we're on the latest
if (is_page_template('templates/the-latest.php') ):
if (is_page_template('templates/the-latest.php') ):
return;
endif;
if (isset( $tag )) {
Expand All @@ -25,11 +25,6 @@
'value' => 'english',
'compare' => '!=',
),
array(
'key' => 'phila_select_language',
'value' => '',
'compare' => '!=',
),
),
)
);
Expand All @@ -54,11 +49,6 @@
'value' => 'english',
'compare' => '!=',
),
array(
'key' => 'phila_select_language',
'value' => '',
'compare' => '!=',
),
),
)
);
Expand All @@ -67,11 +57,11 @@
$is_translated = new WP_Query( $translations );
$langs = array();

while ( $is_translated->have_posts() ) : $is_translated->the_post();
while ( $is_translated->have_posts() ) : $is_translated->the_post();
$lang = rwmb_meta('phila_select_language', '', $post->ID);
$langs[$lang] = $lang;
endwhile;

$unique_langs = phila_order_languages(array_unique($langs));

if (!empty($tag)) {
Expand All @@ -90,7 +80,7 @@
<h2 id="posts">Posts</h2>
<ul class="translated-list">
<?php foreach ($unique_langs as $lang): ?>
<?php if ($lang === 'english') :
<?php if ($lang === 'english') :
$url = '/the-latest/archives/?templates=post&language=english';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -102,7 +92,7 @@
?>
<li><a href="<?php echo $url; ?>">English</a></li>
<?php endif; ?>
<?php if ($lang === 'spanish') :
<?php if ($lang === 'spanish') :
$url = '/the-latest/archives/?templates=post&language=spanish';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -114,7 +104,7 @@
?>
<li><a href="<?php echo $url; ?>">Español</a></li>
<?php endif; ?>
<?php if ($lang === 'chinese') :
<?php if ($lang === 'chinese') :
$url = '/the-latest/archives/?templates=post&language=chinese';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -126,7 +116,7 @@
?>
<li><a href="<?php echo $url; ?>">中文</a></li>
<?php endif; ?>
<?php if ($lang === 'vietnamese') :
<?php if ($lang === 'vietnamese') :
$url = '/the-latest/archives/?templates=post&language=vietnamese';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -137,7 +127,7 @@
}?>
<li><a href="<?php echo $url ?>">Tiếng Việt</a></li>
<?php endif; ?>
<?php if ($lang === 'russian') :
<?php if ($lang === 'russian') :
$url = '/the-latest/archives/?templates=post&language=russian';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -148,7 +138,7 @@
}?>
<li><a href="<?php echo $url ?>">Pусский</a></li>
<?php endif; ?>
<?php if ($lang === 'french') :
<?php if ($lang === 'french') :
$url = '/the-latest/archives/?templates=post&language=french';
if (!empty($term)) {
$url .= '&tag=' . $term->name;
Expand All @@ -164,5 +154,5 @@
</div>
<?php else: ?>
<h2 id="posts">Posts</h2>
<?php endif; ?>
<?php endif; ?>
<?php wp_reset_postdata();?>
15 changes: 0 additions & 15 deletions wp/wp-content/themes/phila.gov-theme/templates/the-latest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
<div>Posts</div>
</a>
</li>
<li class="action_guide cell medium-auto small-24">
<a href="#action-guides">
<i class="fas fa-users fa-fw fa-3x" aria-hidden="true"></i>
<div>Action guides</div>
</a>
</li>
<li class="event cell medium-auto small-24">
<a href="#events">
<i class="far fa-calendar-check fa-fw fa-3x" aria-hidden="true"></i>
Expand Down Expand Up @@ -99,15 +93,6 @@
</div>
</section>

<section>
<div id="action-guides" data-magellan-target="action-guides">
<header class="row columns mtl">
<h1>Action guides</h1>
</header>
<?php get_template_part('partials/posts/action-guide', 'grid'); ?>
</div>
</section>

<section>
<div id="events" data-magellan-target="events">
<header class="row columns mtl">
Expand Down

0 comments on commit 193cf76

Please sign in to comment.