Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialcsj
12,678 PointsHelp with unhook or disable WordPress galleries native behavior.
Help with unhook or disable WordPress galleries native behavior.
Hi Treehouse,
I'm trying to stop the WordPress default behavior, that loads galleries as part of the_content. Becasue I want to call the get_post_gallery
myself so that it become a separate element in the markup.
<?php /* The loop */
while ( have_posts() ) : the_post();
if ( get_post_gallery() ) :
echo get_post_gallery();
endif;
endwhile;
?>
And make it possible for me to add custom fields in-between the the_content
and the gallery.
I've been looking at the media.php in the wp-includes folder for clues. I'm not sure how to go about this. From what I can see it's a filter hook... I've been trying to Google how to unhook the gallery from firing by default. But no luck.
Can anyone help me achieve this? Or know how to pull it off?
Thanks. I hope my question makes sense.
csj
12,678 PointsHey Doru Marginean, wow thanks...
I haven't had the opportunity yet to test this out, but I will soon. Hopefully I can let you know that it works. Thanks again.
Doru Marginean
2,290 PointsDoru Marginean
2,290 PointsHi Christian Steen Jørgensen,
You can try the following code into functions.php
And your single.php would look something like this inside the loop: