Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
makura-2025
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Raj Shah
makura-2025
Commits
39e1c0da
Commit
39e1c0da
authored
Jun 04, 2025
by
rajshah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed: handle related case study section if no items are selected
parent
c2c083a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
3 deletions
+76
-3
related-portfolio-section.php
blocks/related-portfolio-section.php
+76
-3
No files found.
blocks/related-portfolio-section.php
View file @
39e1c0da
...
...
@@ -8,10 +8,11 @@
<?php
the_field
(
'description'
);
?>
</div>
</div>
<?php
if
(
$portfolios
=
get_field
(
'related_portfolios'
))
:
?>
<?php
$portfolios
=
get_field
(
'related_portfolios'
);
if
(
is_array
(
$portfolios
)
&&
!
empty
(
$portfolios
))
:
?>
<div
class=
"portfolio-carousel owl-carousel owl-theme"
>
<?php
foreach
(
$portfolios
as
$portfolio
)
:
// Check if $portfolio is an object or an ID
$post_id
=
is_object
(
$portfolio
)
?
$portfolio
->
ID
:
$portfolio
;
?>
<div
class=
"item"
>
...
...
@@ -64,7 +65,79 @@
<?php
endforeach
;
?>
</div>
<?php
endif
;
?>
<?php
else
:
$current_post_id
=
get_the_ID
();
$current_post_type
=
get_post_type
(
$current_post_id
);
$taxonomy
=
(
$current_post_type
===
'case-study'
)
?
'case-study-category'
:
'portfolio-category'
;
$terms
=
get_the_terms
(
$current_post_id
,
$taxonomy
);
if
(
$terms
&&
!
is_wp_error
(
$terms
))
{
$term_ids
=
wp_list_pluck
(
$terms
,
'term_id'
);
$args
=
array
(
'post_type'
=>
$current_post_type
,
'posts_per_page'
=>
6
,
'post__not_in'
=>
array
(
$current_post_id
),
'tax_query'
=>
array
(
array
(
'taxonomy'
=>
$taxonomy
,
'field'
=>
'term_id'
,
'terms'
=>
$term_ids
,
),
),
);
$related_query
=
new
WP_Query
(
$args
);
if
(
$related_query
->
have_posts
())
:
?>
<div
class=
"portfolio-carousel owl-carousel owl-theme"
>
<?php
while
(
$related_query
->
have_posts
())
:
$related_query
->
the_post
();
?>
<div
class=
"item"
>
<div
class=
"recent-card-wrapper"
>
<a
href=
"
<?php
the_permalink
();
?>
"
>
<?php
if
(
has_post_thumbnail
())
{
the_post_thumbnail
();
}
else
{
if
(
$current_post_type
===
'case-study'
)
{
$case_study_fallback_image
=
get_field
(
'case-study_fallback_featured_image'
,
'option'
);
if
(
$case_study_fallback_image
)
{
echo
'<img src="'
.
esc_url
(
$case_study_fallback_image
)
.
'" alt="Case Study Placeholder">'
;
}
}
}
?>
<div
class=
"bottom-text"
>
<div
class=
"d-flex align-items-center justify-content-between title"
>
<div
class=
"heading"
>
<h3>
<?php
the_title
();
?>
</h3>
</div>
<div
class=
"site-link"
>
<p>
View Site
<!-- SVG here -->
</p>
</div>
</div>
<ul
class=
"list-unstyled d-flex"
>
<?php
$related_terms
=
get_the_terms
(
get_the_ID
(),
$taxonomy
);
if
(
$related_terms
&&
!
is_wp_error
(
$related_terms
))
{
foreach
(
$related_terms
as
$term
)
{
echo
'<li>#'
.
esc_html
(
$term
->
name
)
.
'</li>'
;
}
}
?>
</ul>
</div>
</a>
</div>
</div>
<?php
endwhile
;
?>
</div>
<?php
endif
;
wp_reset_postdata
();
}
endif
;
?>
<?php
if
(
$link
=
get_field
(
'link'
))
:
$link_target
=
$link
[
'target'
]
?
$link
[
'target'
]
:
'_self'
;
?>
<a
href=
"
<?php
echo
$link
[
'url'
];
?>
"
target=
"
<?php
echo
esc_attr
(
$link_target
);
?>
"
class=
"btn my-60 mx-auto d-flex align-items-center start-project btn-start-project-white"
style=
"width: fit-content;"
>
<?php
echo
$link
[
'title'
];
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment