Query on CPT field

My CPT ‘publication’ has fields including

  • hps_page_number
  • hps_edition_number

I have a regular page with a looper provider with this query string: post_type=publication&orderby=meta_value_num&meta_key=hps_page_number&order=asc

It pulls posts from a CPT called publication and sorts them by page number - this is working.

I want to pass a URL into the page such as ?edition=47 and filter the looper provider results, e.g.:

post_type=publication&orderby=meta_value_num&meta_key=hps_page_number&order=asc&hps_edition_number={{dc:url:param key=“edition”}}

or {{dc:term:meta key=“hps_edition_number”}}={{dc:url:param key=“edition”}}
or {{dc:acf:post_field field=“hps_edition_number”}}={{dc:url:param key=“edition”}}7

I got help from the Facebook group and this is the string that works.

post_type=publication&orderby=meta_value_num&meta_key=hps_page_number&order=asc&meta_query[0][key]=hps_edition_number&meta_query[0][value]={{dc:url:param key=“edition” fallback=“46”}}&meta_query[0][compare]==&meta_query[relation]=AND

This means I can simulate an archive layout but with sorting, and parameterise the page using the input URL.

No need for help but this might provide a guide for visitors from the future.

1 Like

Two dynamite websites which help are these:

Create your query in the first, then use the second to translate to the http query string format, and paste into your looper query string.

1 Like

Hi Bill,

Thanks for sharing the detailed information. It will surely help others.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.