Questions tagged [wp-parse-args]

wp_parse_args is a generic utility for merging together an array of arguments and an array of default values. It can also be given a URL query type string which will be converted into an array (i.e. "id=5&status=draft").

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Hide child of parent categories already hidden with "get_terms_args" - Woocommerce

I would need your help as I am unable to hide subcategories, or rather, child categories of already hidden and defined categories. I tried entering $args['parent'] = 0; but it hides all the parent ...
  • 23
0 votes
0 answers
16 views

Filter wordpress query by numerical order arguments

I have some programs that go according to the day but I want it to be filtered by custom field such as menu_order, that is, by numerical position through ordernum that I can give it This doesn't show ...
0 votes
0 answers
25 views

Exclude Woocommerce Product Category From Sitemap

Am trying to exclude 2 specific product categories from default WordPress sitemap. Any help how to archive this? add_filter( 'wp_sitemaps_posts_query_args', function( $args, $post_type ) { if ( ...
  • 35
1 vote
0 answers
53 views

Query posts(CPT, pages , hierarchical) by Ancestor ID

so i have a custom post type with hierarchical structure. Looks like this: top level 1 - child -- grand child -- grand child - child -- grand child top level 2 - child ...
  • 11
0 votes
1 answer
1k views

How do I add a separator to my list of terms with get_category

I have this... $args = array('child_of' => 3422 ); $categories = get_categories( $args ); foreach($categories as $category) { echo '<a href="' . get_category_link( $category->term_id ) ....
  • 976
0 votes
0 answers
147 views

Display all posts from specific category and CPT

Currently, we are getting all posts from a specific category using the following: $args = array( 'post_type' => array('post'), 'cat' => 1247, 'posts_per_page' => 4 ); What we'd ...
  • 101
0 votes
1 answer
2k views

$args for get_terms() to return ORDER BY FIELDS

I want to use get_terms() for a taxonomy in such as way as to emulate MySQL's ORDER BY FIELD e.g., ...FIELD ('aaa','ccc','bbb','eee','ddd') A var_dump snippet currently looks like: object(WP_Term)#...
2 votes
2 answers
2k views

wp parse_query not working with custom meta value

I've a custom post type with some custom meta box. I want to filter my custom post type posts using custom meta value. I've written the code below. But it return no post found. Can anyone tell me ...
  • 23
0 votes
0 answers
159 views

Include search tags and users in my search results system

This is my codes for search posts by ajax: PHP: public function search_posts(){ try { $data = $_POST['content']; $data = wp_parse_args( $data, array( 'post_type' =...
  • 113
1 vote
1 answer
97 views

Custom Taxonomy Archive BUG

I'm hoping that Its just my tired eyes missing something and a fresh pair of eyeballs might catch what I'm missing. I have a custom taxonomy with a slug of 'residential_project_types' that is ...
0 votes
1 answer
2k views

How to create frontend Post filter using meta query

I have created a post filter like the image below, but I have an issue with selecting multiple values from different fields. All the fields in the filter are custom fields. The thing is, in the admin ...
1 vote
1 answer
3k views

Remove h2 Tag in screen_reader_text

How can I remove the h2 tag used in the screen reader text? I use the following $args, but h2 is still in it: the_comments_pagination( array( 'add_fragment' => '', 'screen_reader_text' =&...
0 votes
2 answers
2k views

How to pass a variable for key/value pairs in an argument?

For example, this works: 'default' => '#ffffff' But this does not: $white = '#ffffff'; 'default' => $white How can I pass variables to key/value pairs? Here is a more complete example for ...
  • 121
0 votes
1 answer
408 views

Custom nav walker: How to acces the $args parameter?

I am creating a custom nav walker. I noticed that the nav walker class from the WordPress core is written rather rough – much of the stuff going on could be spread out through various methods, so I ...
  • 371
22 votes
1 answer
22k views

How to modify a taxonomy that's already registered

Today I needed to change the arguments on a custom taxonomy that was already registered by a third party plugin. Specifically I wanted to set the show_admin_column argument to true and change the ...
  • 9,957
1 vote
2 answers
1k views

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => ASC )); All ...
  • 45
2 votes
0 answers
2k views

Ajax form filter post by custom fields [closed]

I'm currently working on a site where users can search for apartments. I have a custom post type for the apartment posts, which contain several custom fields. I have a page where i list all of the ...
  • 147
0 votes
2 answers
642 views

post__in - Placing content from a foreach loop inside of an array

I know this code is incorrect, but it's a basis of what I am trying to achieve. I am parsing an xml feed via PHP and running a foreach loop to get a value from a specific key. Here is the snippet I ...
  • 463
2 votes
1 answer
642 views

How to implement time filter to show random post 1 month for one category and 3 months for other categories

I started to work on one website after another developer and there is problem with his "popular widget" which is basically showing 3 random posts from category. There is some Switch statement which is ...
  • 169
0 votes
1 answer
640 views

Get WP_Query query after execution?

It it possible to get the configuration of a the latest called WP_Query? I need to use it for debugging. For example, if i run something like: $the_query = new WP_Query( $args ); ... Could i get ...
  • 655
1 vote
1 answer
2k views

Using wp_parse_args to set up Plugin Default Settings

So I want to have defaults set up for each of my plugins settings, and I'm using wp_parse_args to do so which I believe is the correct way, but I'm hitting a roadblock. Here's my code at the moment: ...
1 vote
1 answer
299 views

Creating a Search Array From Multiple Tables

I'm working with a client's WordPress site that has user submissions (via TDO Mini Forms) from multiple countries, and they would like to be able to search for posts by region – Europe, Africa, ...
  • 139
0 votes
1 answer
685 views

when the incoming url is a query, in which function does WP begin to work with it?

I need to debug a problem with filters I have in place. they're affecting any url that includes a query; eg, http://my.domain.hk/?attachment=1. does anyone know in which function WP begins to work ...
  • 539
1 vote
1 answer
1k views

wp_parse_args & category parameter

Am trying to use this code: function wp_custom_archive($args = '') { global $wpdb, $wp_locale; $defaults = array( 'cat' => 6, //doing nothing 'format' =&...
  • 1,062