Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Query string for Query Loop Links?

  • Hi there,

    Is there anyway to add query strings to query loops such as a utm_source etc. so I can tell the traffic came from that query loop?

    Currently, it has dynamic links, but does not allow me to add any query string after it.

    Kind regards,

    Will

  • Hi Will,

    Do you want to add the query string to the headline block in a query loop block?

    If so, you might be able to use the generateblocks_dynamic_url_output filter to add it.

  • I am using the dynamic data linking for a headline, let’s say a query loop for posts.

    However, I want every link in the query loop of that dynamic link data to have a ?____ added to the end where ___ could be any query string – does that make sense?

    Kind regards,

    Will

  • What a coincidence. I was coming to the forum to see if that’s possible.

    I use Matomo and I’d be really curious to know if the same link gets more clicks between the Headline, Image or Button inside a Query Loop. The sort of insight that can help figure out how to make a layout more effective.

  • However, I want every link in the query loop of that dynamic link data to have a ?____ added to the end where ___ could be any query string – does that make sense?

    Yes, you can use the generateblocks_dynamic_url_output to add extra content to the link.

    Try this:

    1. Add a class to the headline you want to target, eg. add_query_string.

    2. Add this PHP code, replace '?____' with actual code.

    add_filter('generateblocks_dynamic_url_output','add_query_string_to_dynamic_link', 20,2);
    function custom_query_loop_pagination($url , $attributes) {
    	if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'add_query_string'  === $attributes['className'] )  {
                    $query_string = '?____';
    		$url = $url.$query_string; 
    	}
    	return $url;
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.