Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Wordpress Gallery is not displaying

I have developed a custom wordpress theme from scratch. I'm having a issue in it. When I try to use native wordpress gallery shortcode in my post or page, It is display fine in the editor but its not displaying on the front end.

enter image description here

I even tried it by using:

echo do_shortcode('[gallery columns="5" link="none" ids="70,69,68,67"]');

But nothing has shown up...

Other post / page content is displaying fine but just gallery is not displaying. Its like its not even generating anything on the front-end.

If I switched the theme to any other theme it work but not in my theme, so its clear that its a theme problem. Do I have to add some kind of theme support for the gallery?

Any help would be appreciated :)


Update: 2 May, 2017

I'm using pre_get_posts hook which causing the problem. Can someone help me understand why?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Waited a lot but couldn't find an answer... I found the issue but doesn't know how to resolve it. But fortunately there is a way around it.

I have been using wordpress's pre_get_posts hook to set a tax_query which looks like this:

add_action( 'pre_get_posts', 'homeInjector' );

function homeInjector( $query ) {

        if ( $query->is_home() ) {

            $issues = get_terms( array(
                'taxonomy' => 'issues'
            ) );

            if ( isset( $_POST['issue'] ) ) {
                $term = $_POST['issue'];
            } else {
                $term = $issues[0]->slug;
            }


            $arg = array(
                array(
                    'taxonomy' => 'issues',
                    'terms'    => $term,
                    'field'    => 'slug'
                )
            );

            $query->set( 'tax_query', $arg );

        }

but if I use same code in index.php with new WP_Query object it works!

$issues = get_terms( array(
    'taxonomy' => 'issues'
) );

if ( isset( $_POST['issue'] ) ) {
    $term = $_POST['issue'];
} else {
    $term = $issues[0]->slug;
}

$qry = new WP_Query( array(
    'post_type' => 'post',
    'tax_query' => array(
        array(
            'taxonomy' => 'issues',
            'terms'    => $term,
            'field'    => 'slug'
        )
    )
) );

Don't know why but it works...

But still I'll wait for the appropriate answer because mine is just a way around to help me and others :)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!