• Resolved thebigtine

    (@josephbydesign)


    I have this shortcode that runs another gallery shortcode. I am trying to filter the posts that are being displayed.

    This dosen’t work (note the post_taxonomy_term="' . $_GET['cat'] .'"]'):

    function want_filter_lookbook_shortcode_callback($atts, $content, $name){
    
      	// Build output
    
      	$output = do_shortcode( '[cactus-masonry masonry="true" quality="large" link_location="full" display_post_titles="true" width="33.33%" show_lightbox="true" show_lightbox_title="true" browse_with_lightbox="false" custom_post_types="portfolio-item" post_taxonomy="portfolio-category" post_taxonomy_term="' . $_GET['cat'] .'"]' );
    
      	return $output;
    }

    But this does:

    function want_filter_lookbook_shortcode_callback($atts, $content, $name){
    
      	// Build output
    
      	$output = do_shortcode( '[cactus-masonry masonry="true" quality="large" link_location="full" display_post_titles="true" width="33.33%" show_lightbox="true" show_lightbox_title="true" browse_with_lightbox="false" custom_post_types="portfolio-item" post_taxonomy="portfolio-category" post_taxonomy_term="bottoms"]' );
    
      	return $output;
    }

    So when I hard code the value instead of using $_GET it works.
    This is the exact url: http://dev.want.ca/?page_id=16?cat="bottoms"

    Any ideas why?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Are the quotes actually part of the URL, as in your example? If so you’re basically doing:

    post_taxonomy_term=""bottoms""]

    Which means the post_taxonomy_term attribute is empty. If whatever is adding cat=”” to the URL is something you wrote, I’d recommend taking the quotes out. If you have no control over that, just omit the quotes from your shortcode function:

    post_taxonomy_term=' . $_GET['cat'] . ']'

    Thread Starter thebigtine

    (@josephbydesign)

    @jakept

    Yes thankfully I do have control over the generated links. Thanks that worked a treat.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$_GET not working in shortcode’ is closed to new replies.