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
-1 votes
1 answer
96 views

How to filter by category name in custom post types?

$args = array( 'post_type' => 'fruits', 'posts_per_page' => 4, 'category' => 'apple' ); ...
Jhon Fer's user avatar
1 vote
0 answers
62 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 ...
Piotr's user avatar
  • 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 ) ....
Pete's user avatar
  • 998
0 votes
0 answers
234 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 ...
BN83's user avatar
  • 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)#...
breadwild's user avatar
  • 319
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 ...
S.k.joy's user avatar
  • 23
0 votes
0 answers
160 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' =...
Trello's user avatar
  • 111
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 ...
user5176291's user avatar
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 ...
Alvin Ofori-Adjei's user avatar
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' =&...
RodneyHawk's user avatar
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 ...
Rokit's user avatar
  • 121
0 votes
1 answer
431 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 ...
Sven's user avatar
  • 371
23 votes
2 answers
24k 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 ...
mrwweb's user avatar
  • 10.2k
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 ...
coder's user avatar
  • 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 ...
TietjeDK's user avatar
  • 147
0 votes
2 answers
724 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 ...
Roc's user avatar
  • 463
2 votes
1 answer
697 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 ...
levat's user avatar
  • 169
0 votes
1 answer
671 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 ...
qwerty's user avatar
  • 665
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: ...
bryceadams's user avatar
1 vote
1 answer
301 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, ...
Ty Morton's user avatar
  • 139
0 votes
1 answer
686 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 ...
Gregory's user avatar
  • 569
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' =&...
kevin's user avatar
  • 1,062