Forum Replies Created
-
AuthorPosts
-
elvin
ModeratorHi Ema,
All my CPT event posts have the ACF field of ‘start_date’ – how does this only show the current events.
It should be possible but we’ll have to resort to a bit of modification to the plugin’s file.
Make this change in your wp-show-posts.php file: https://github.com/tomusborne/wp-show-posts/commit/286caf1164db8b6b6f38b85d3a011b519a27f4de
We then need to do some filtering. The PHP will be something like this:
add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) { if ( 4943 === $settings['list_id'] ) { $args['meta_query'] = array( array( 'key' => 'start_date', 'orderby' => 'meta_value_num', 'order' => 'DESC', ) ); } return $args; });
The
key
params’ value is your ACF slug. Theorder
param value is there sorting order depending on what you’ve set onorderby
param. These order params can be omitted.elvin
ModeratorHi Ema,
Hello! is there a way that I can show posts from a Category that spans all 4 of my CPTs?
It should be possible but we’ll have to resort to a bit of modification to the plugin’s file and a bit more custom PHP for filtering the query.
Make this change in your wp-show-posts.php file: https://github.com/tomusborne/wp-show-posts/commit/286caf1164db8b6b6f38b85d3a011b519a27f4de
The PHP will be something like this:
add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) { if ( 123 === $settings['list_id'] ) { $args['post_type'] = array('post','custom_post_type_slug_1','custom_post_type_slug_2','custom_post_type_slug_3'); $args['tax_query'] = array( 'relation' => 'OR', array( 'taxonomy' => 'topics', 'field' => 'slug', 'terms' => array( 'featured','another-topic-term' ), ) ); } return $args; } );
Change
123
to the WPSP list ID you’re displaying this on and change$args['post_type'] = array('post','custom_post_type_slug_1','custom_post_type_slug_2','custom_post_type_slug_3');
to add the post type slugs.You’ll also have to change
'terms' => array( 'featured','another-topic-term' ),
array slugs to featured + other “Topics” term slugs you want to include. 😀February 9, 2022 at 7:06 pm in reply to: My account has yet to be migrated to GenerateBlocks. #36564elvin
ModeratorHi there,
The team is still processing through the list of users who filled the form. There’s a bit of a slowdown as this move coincided w/ WordPress 5.9’s release but it’s still being checked. 😀
As WPSP’s license expiring:
If the worry is WPSP not working after it’s license expiry, you can rest assured that it’ll continue to work.
The license is mainly to have the privilege to update the plugin and receive support. Since there’ll be no further updates until the merge w/ GB, the installed plugin can stay as it is. 🙂
Support will still be provided. I’ll make sure to go back to this and let everyone know about any updates. 😀
elvin
ModeratorNo problem. Let us know if you need further help. 😀
January 24, 2022 at 4:45 pm in reply to: My account has yet to be migrated to GenerateBlocks. #36469elvin
ModeratorHi there,
The request from the form you’ve filled in requires a bit of processing.
You should receive an email through the email address you’ve provided, specifying the steps to claim your GenerateBlocks Pro license once Tom has processed the request.
Let us know if you have further questions. 🙂
elvin
ModeratorNo problem. 😀
elvin
ModeratorHi Ben,
There are 2 ways to do this.
You can either do this using shortcode.
Example:
[wp_show_posts id="761" settings="taxonomy=category&tax_term=post-cat-1, post-cat-2"]
or through the WPSP edit list’s Meta tab as shown here
-https://share.getcloudapp.com/7KuqAeldelvin
ModeratorHi Hans,
The link is hard-coded, unfortunately.
https://github.com/tomusborne/wp-show-posts/blob/35e410d7800273fc66f211c0f80d553e95d17f83/wp-show-posts.php#L439Consider adding it using a javascript.
Something like:
var title_link = document.querySelectorAll('.wp-show-posts-entry-title > a'); for (var i=0; i<title_link.length; i++){ title_link[i].setAttribute('target', '_blank'); }
Hook this on your site’s wp_footer.
elvin
ModeratorThere’s no complete documentation for this, unfortunately.
There will likely be one when GenerateBlocks gets merged with WP Show Posts and it’ll likely be posted as part of GB’s documentation.
For now, you can ask us here for any specific parameters or you can search around the forums for shortcode usages. 🙂
elvin
ModeratorHi there,
You can do it like this:
[wp_show_posts id="18" settings="taxonomy=post_tag&tax_term=test-tag-1&tax_operator=NOT IN"]
Use tag slug on
tax_term=
elvin
ModeratorThanks for letting us know. Glad you got it sorted. 😀
elvin
ModeratorWould be awesome if some day Tom decides to add this simple option( in More settings -> Order by) to the WP Show Post Block when ported to GenerateBlocks. This will make your plugin more polyvalent and useful.
Now may be a good time to suggest a feature since Tom’s in the process of merging WPSP and GB. Perhaps he can add things in while he’s at it.
You can raise a feature request here –
https://community.generateblocks.com/c/feature-requests/6And/or here-
https://github.com/tomusborne/generateblocksalthough I suggest going through the community first so it gets more votes, so Tom finds it something to prioritize. 🙂
elvin
ModeratorAh I see why the code wasn’t working.
This code assumes your posts already have a
post_views_count
meta on them. I’ve checked the site and the posts doesn’t have this meta.The post counting meta is something you’ll have to apply to the posts. It’s not something WP Show Posts automatically adds.
You’ll either need a plugin for that or create the custom functionality for it.
elvin
ModeratorIs it solely for sorting the posts?
If it’s solely for sorting the posts then I think what you need is $args[‘orderby’] and $args[‘order’].
add_filter( ‘wp_show_posts_shortcode_args’, function( $args, $settings ) { if ( 9463 === $settings[‘list_id’] ) { $args[‘orderby’] = 'meta_value_num'; $args['meta_key'] = 'post_views_count'; $args['order'] = 'DESC'; return $args; },10,2);
Use this parameter as reference – https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
elvin
ModeratorAh I see,
I assumed you did the necessary changes to the plugin’s code for this filter to work.
The
Uncaught ArgumentCountError: Too few arguments to function
error is because the current official release takes only 1 arg for thewp_show_posts_shortcode_args
filter.For it to take 2 arguments, you’ll have to do Tom’s instructions here – https://wpshowposts.com/support/topic/can-i-exclude-with-a-custom-meta-field-from-a-list/#post-13344
-
AuthorPosts