We’re presently attempting to create a loop of file downloads from another plugin (Download Manager) that generates its own custom post type (dlm_download). We have a bit of a mix between custom Bootstrap-based .PHP template files and Page Builder to allow for some freedom of layout, but also heavy customization.
While we’d usually run a PHP-based query in one of the templates, the particular layout of this page requires doing so via Page Builder; hence the use of the Post Loop widget. Unfortunately the CPT created by the download plugin is not showing up in the Post Type options.
We’re all set up to add an action to change the $args on this post type in order to force it to show up (as below):
add_action('register_post_type_args', function ($args, $postType) {
if ($postType !== 'dlm_download'){
return $args;
}
$args['ExampleArgument'] = ArgumentSetting;
return $args;
}, 99, 2);
…but instead of cycling through every possible option, we thought it would be easier to ask what arguments are necessary to get this CPT to pop up in the Post Loop > Post Type options.
P.S.: We tried public => true, but encountered a server loop (possibly because we’re trying to run it as an mu-plugin; haven’t checked yet).
Thank you!
]]>v6.2.9
changes… Reporting this bug here since this file is contained within the public calendar plugin and not in a premium add-on plugin.
Issue
Additional term arguments?$params[args]?
for select2 taxonomy dropdowns breaks at?v6.2.9
?to current version. was working prior and the last working version was?v6.2.8.2
.
(e.g. passing exclude, parent etc. as additional arguments is no longer parsed and ignored in ajax response)
action=tribe_dropdown&source=search_terms&search%5B_type%5D=query&search%5Bterm%5D=&args%5Btaxonomy%5D=tribe_events_cat&args%5Borderby%5D=name&args%5Bexclude%5D%5B%5D=69
action=tribe_dropdown&source=search_terms&search%5B_type%5D=query&search%5Bterm%5D=&args%5Btaxonomy%5D=tribe_events_cat&args%5Borderby%5D=name&args%5Bparent%5D%5B%5D=69
Where
Issue found in class?Tribe__Ajax__Dropdown
?in file:?the-events-calendar/common/src/Tribe/Ajax/Dropdown.php
A change to function parse_params($params)
as of?v6.2.9
?is breaking the ability to pass any additional arguments to?get_terms()
.
Specifically, the issue is on?line 251?as the default value ignores any additional params passed with the ajax post. Instead there’s 2 conditionals for the args array only checking for taxonomy
and post_type
preventing any additional term args to be parsed…
Quick fix
line 251:?'args'? => [ 'post_status' => 'publish' ],
a quick fix would be to change this line to:?'args'? => $params['args'] ?? [ 'post_status' => 'publish' ],
- 'args'? => [ 'post_status' => 'publish' ],
+ 'args'? => $params['args'] ?? [ 'post_status' => 'publish' ],
v6.3.6 parse_params()
Recommendation: Adjust whitelist to include all allowed term arguments accepted by get_terms()
/**
* Parses the Params coming from Select2 Search box.
*
* @since 4.6
* @since 5.1.17 Added an allow list of params to restrict the shape of the database queries.
*
* @param array<string|mixed> $params Params to overwrite the defaults.
*
* @return object
*/
public function parse_params( $params ) {
$allowed_params = [
'search' => $params['search'] ?? null,
'page' => $params['page'] ?? 0,
'source' => $params['source'] ?? null,
'args' => [ 'post_status' => 'publish' ],
];
if ( isset( $params['args']['taxonomy'] ) ) {
$allowed_params['args']['taxonomy'] = $params['args']['taxonomy'];
}
if ( isset( $params['args']['post_type'] ) ) {
$allowed_params['args']['post_type'] = $params['args']['post_type'];
}
// Return Object just for the sake of making it simpler to read.
return (object) $allowed_params;
}
v6.2.8.2 parse_params()
Passing additional term arguments for additional get_terms() filter is working properly.
/**
* Parses the Params coming from Select2 Search box
*
* @since 4.6
*
* @param array<string|mixed> $params Params to overwrite the defaults
*
* @return object
*/
public function parse_params( $params ) {
$defaults = [
'search' => null,
'page' => 0,
'args' => [],
'source' => null,
];
$arguments = wp_parse_args( $params, $defaults );
// Return Object just for the sake of making it simpler to read
return (object) $arguments;
}
Please this fix this,
Thanks!
– Scott Trsar
Initially I used the method with arguments:
$args['meta_query']['relation'] = 'AND';
$args['orderby'] = 'length(meta_value)';
$args['order'] = 'ASC';
$args['limit'] = '1';
foreach($nominativo as $tag) {
if (trim($tag) != '')
{
$args['meta_query'][] = array( 'key' => 'billing_company', 'value' => trim($tag), 'compare' => 'LIKE' );
}
}
$user = get_users($args);
It works, but it’s not very accurate because it doesn’t seem to fully accept the length(meta_value) function in order by.
So I was forced to use $wpdb doing a classic select with the same features. Now it works perfectly, except for cases of homonymy, but there is nothing we can do about it.
Let’s get to the point. What surprised me is the difference in script execution speed between the first and second method.
bearing in mind that the script processes several thousand lines, the first method takes about 7 and a half minutes, while the second method takes about 1 and a half minutes.
A huge difference to get the same result.
Could anyone tell me why?
Thank you.
Regards,
Renato
Any help? Am stack!
'wp_sitemaps_posts_query_args',
function( $args, $post_type ) {
if ( 'product_cat' !== $post_type ) {
return $args;
}
$args['product_cat__not_in'] = isset( $args['product_cat__not_in'] ) ? $args['product_cat__not_in'] : array();
$args['product_cat__not_in'][] = 2053;
$args['product_cat__not_in'][] = 924;
return $args;
},
10,
2
);
]]>only search text for title and descriptión, i need search in all post meta dinamic fields or custom field ej: _custom-text-20
would it be possible to add it here?
add_filter( ‘atbdp_listing_search_query_argument’, function( $args ){
}
]]>$arg['label_submit'] = __(Post Comment ';
in functions.php. I am using my own custom comments.php file.I am developing with WP since, I would say a bit more then 14 months now.
Since a couple of days, i have the awesome ToDo, to create a Portfolio with an Ajax request, and I am stuck …
Facts:
I have 3 different taxonomies:
‘taxonomy’ => ‘auftragsgrafik_slug_list’,
‘field’ => ‘slug’,
‘terms’ => $typefilter,
‘taxonomy’ => ‘thema’,
‘field’ => ‘slug’,
‘terms’ => $themefilter,
‘taxonomy’ => ‘auftragsgrafik_complexity’,
‘field’ => ‘slug’,
‘terms’ => $complexityfilter,
I try to explain it “short”..
3 Dropdowns, each of it has a bunch of values.
Lets say:
.) Dropdown A (‘auftragsgrafik_slug_list‘)
–> TestA
–> TestB
–> TestC
.) Dropdown B (‘thema‘)
–> LunchA
–> LunchB
–> LunchC
–> LunchD
–> LunchE
–> LunchF
.) Dropdown C (‘auftragsgrafik_complexity‘)
–> CoffeeA
–> CoffeeB
–> CoffeeC
–> CoffeeD
–> CoffeeE
(u got the Idee)
If now “TestA” is selected, I just want all Post results where the Taxonomy is linked with TestA.
If TestA and LunchA is selected, I want only the Post results where both “TestA AND LunchA” are linked via taxonomies to the posts!
If TestA, LunchA and CoffeeA is selected, I just want Post results where all 3 Taxonomies match with posts!
I googled, tried, worked, but I found no working Solution for me :/
My actuall work looks kinda like this:
I just post the code for 1 Request here, to avoid a bit of spam!
$args = array(
'posts_per_page' => $entries,
'meta_query' => array(array('key' => '_thumbnail_id')),
'post_type' => 'auftragsgrafik_post',
'post_status' => 'publish',
'tax_query' => array(
array(
'relation' => 'OR',
array(
'taxonomy' => 'auftragsgrafik_slug_list',
'field' => 'slug',
'terms' => $typefilter,
'relation' => 'OR',
),
array(
'taxonomy' => 'thema',
'field' => 'slug',
'terms' => $themefilter,
'relation' => 'OR',
),
array(
'taxonomy' => 'auftragsgrafik_complexity',
'field' => 'slug',
'terms' => $complexityfilter,
)
),
'relation' => 'OR',
array(
'taxonomy' => 'auftragsgrafik_slug_list',
'field' => 'slug',
'terms' => $typefilter,
'relation' => 'AND',
array(
'taxonomy' => 'thema',
'field' => 'slug',
'terms' => $themefilter,
),
),
'relation' => 'OR',
array(
'taxonomy' => 'auftragsgrafik_slug_list',
'field' => 'slug',
'terms' => $typefilter,
'relation' => 'AND',
array(
'taxonomy' => 'auftragsgrafik_complexity',
'field' => 'slug',
'terms' => $complexityfilter,
),
),
),
);
I definitely know that this can not work, I spend to much time now to know it… so I need some Guidance here my friends :-/
PLEASE
What is the best way to make it work with my specific requirements?
I also tried it to make multiple “args” and merge those together, but sadly I don’t get it to work..
I hope you have the Knowledge, in which I am leaking… hope you can help me
Nice greetings, Raphael
]]>I’m using the following to display my login page in a child theme however the plugin isn’t adding in the Auth code field.
Do I need to pass any additional args?
$args = array( 'redirect' => home_url().'/dashboard',
'label_username' => __( '' ),
'label_password' => __( '' )
);
wp_login_form($args);
]]>This is my current code, what am I missing?
<?php
global $post;
$args = array( ‘post_count’ => 12, ‘posts_per_page’ => 4, ‘category_name’ => ‘home-feed’ );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
?>
<div class=”row post-stream”>
<div class=”col-md-3 col-sm-4 col-xs-12″>
“><?php echo get_the_post_thumbnail( $post_id, ‘large’ ); ?>
</div>
<div class=”col-md-9 col-sm-8 col-xs-12″>
<div style=”min-height: 135px;”>
<h4 style=”margin-top: 0;”>
“><?php the_title(); ?>
</h4>
<div class=”feed-date-tags”>
<?php the_date(); ?>
</div>
<p>
<?php echo excerpt(45); ?>
</p>
</div>
“>Read More
</div>
</div>
<hr>
<?php endforeach;
wp_reset_postdata();?>