Home › Forums › Pro Support › Dynamically Show 3 or 4 Posts by Page ID #
- This topic has 5 replies, 2 voices, and was last updated 2 years ago by
elvin.
-
AuthorPosts
-
September 16, 2021 at 6:44 am #33874
Alan
ParticipantI am using Genesis Blocks to display either 3 or 4 tours (CPTs selected by me as recommended tours) on over two hundred pages. This is a custom application that adds a lot of code to the blog posts, pages, and website. I am using WPSP grids created by me elsewhere on the site (see all destination and interest pages) and would like to know if I can dynamically create grids of 3 or 4 posts with WPSP. Right now, I have 77 WPSP lists and don’t want to add more. If I can do what I want dynamically, I can also reduce the list count dramatically.
Here is an example of 3 tours created with Genesis Blocks. See Recommended Tours at bottom of post https://www.savacations.com/galapagos-giant-tortoise-23-interesting-facts/.
Here is an example of 4 tours created same way. See Tours Featuring https://www.savacations.com/destinations/ecuador-tours-travel/ecuador-accommodations/hotel-dann-carlton-quito/.
I want to know if I can create the same thing by just dynamically adding the page id numbers into a WPSP short code. I am already doing the same thing now (see FAQ, Weather, and Accommodations on the destination pages), but need to create a new list in WPSP to do it, which I want to avoid.
Please let me know. Thanks,
September 16, 2021 at 7:39 pm #33893elvin
ModeratorHi Alan,
You can reuse a single WPSP list and have it do different queries on each instance through shortcode.
Here’s a list of examples you can do w/ shortcode.
https://wpshowposts.com/support/topic/shortcode-parameters-documentation/#post-29167And you can do multiple instance of this throughout the site or within the same post.
Say for example, you want to use list id 1234 on the same page but you want it to display different queries for each instance, you can do something like this:
Here’s an instance where the list queries category with slug “humanities”
[wp_show_posts id="1234" settings="taxonomy=category&tax_term=humanities"]
Here’s an instance where the list queries sorted by post views in ascending order.
[wp_show_posts id="1234" settings="meta_key=post_views_count&orderby=meta_value_num&order=ASC"]
Here’s an instance where the list queries specifying post IDs to display:
[wp_show_posts id="1234" settings="post_id=4403,3904,4002"]
You can use these 3 shortcodes on the same page simultaneously and they will all display different queries. You don’t have to make multiple WPSPs assuming you all want them to have the same styling.
September 17, 2021 at 4:48 am #33913Alan
ParticipantElvin:
That is exactly what I am looking for if I can order the posts the way that I want. The one that is most applicable is here
[wp_show_posts id="1234" settings="post_id=4403,3904,4002"]
. One issue that I can work around if I have to is that you need to choose ascending or descending order, and the posts are displayed (on the web page) accordingly (i,e, 3904,4002,4403 or vice versa). Even if you choose no order from the order by drop-down list I am not aware of how to display the posts in this order 3904,4403,4002. Is it possible to do this?Please let me know.
Thanks,
September 18, 2021 at 9:44 am #33933elvin
ModeratorThis attribute should work.
[wp_show_posts id="1234" settings="post_id=3904,4403,4002&orderby=post__in"]
September 18, 2021 at 11:46 am #33936Alan
ParticipantThat works perfectly. Thanks!!
September 18, 2021 at 12:01 pm #33938elvin
ModeratorNo problem. Glad to be of any help. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.