Get Custom Field Values by Another Custom Field in WordPress

After struggling with this, I found a workaround that worked. Since every custom field has a connection with my custom post type, I was able to use wp_get_object_terms to get the terms for each custom taxonomy. Using the query to retrieve all posts: $args = array( ‘post_type’ => ‘houses’ ); $houses = new WP_Query($args); $posts … Read more

wp parse_query not working with custom meta value

I ave faced the same issue when I was trying to filter custom-post-type with custom-field but I have resolved this issue in the following steps. Converted custom-field name from writer to _writer and then I have updated following code inside callback function of parse_query hook that I can add custom-field meta_query like $query->set( ‘meta_query’, array( … Read more

wp_get_nav_menu_items wp-admin/customize.php problem

I was getting the same fatal error after creating a similar dynamic menu. What fixed the issue for me was redefining the default values: $post->target=””; $post->attr_title=””; $post->description = ”; $post->classes=””; $post->xfn = ”; $post->status=”publish”; $post->original_title=””; So your foreach loop would look like this: foreach ( get_posts( $category_ten_last_posts ) as $post ) { $post->menu_item_parent = $item->ID; … Read more

multiple search forms and search results

If you only want to search a particular post type include a hidden field with the name post_type and the value set as the name of the post type you want to search: <form role=”search” method=”get” action=”https://wordpress.stackexchange.com/”> <input type=”text” name=”s” placeholder=”Search”> <input type=”hidden” name=”post_type” value=”post_type_name”> <input type=”submit” value=”Go”> </form> Just replace post_type_name with the actual … Read more

Admin Column Text Positioning

The Problem If you inspect the column (i.e. the “File Type” column), you’d see something like this markup/HTML: <th scope=”col” id=”0″ class=”manage-column column-0 num”>File Type</th> and this for a td element in that column: <td class=”0 column-0″ data-colname=”File Type”>text/csv</td> So the problem, as you can see in the id and class attributes, is the column’s … Read more

Display custom post types with custom date field value (before today) & order by custom date field

I prefer to use WP_Query (for more info read “When should you use WP_Query vs query_posts() vs get_posts()?“), try this way: $args = array( ‘post_type’ => ‘soiree’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date_de_concert’, // you don’t need ‘meta_key’ => ‘date_de_concert’ when using meta_query //’meta_key’ => ‘date_de_concert’, ‘order’ => ‘DESC’, ‘meta_query’ => array( … Read more

Custom permalink – append taxonomy name and term name at the end of permalink

You can achieve the following permalink structure by simply overriding (without having to remove) the default one (you specified) for the resources post type: /resources/%resources%/resources-type/%resources_type% <- preferred /resources/resources-type/%resources_type%/%resources% <- default And you can override it via add_permastruct() — first, register the post type without specifying the rewrite parameter which means the rewrite defaults to true/enabled … Read more

Sort by two dates. Default entry date and custom field if present

Few issues I see here with your code: You have category_name set to upcoming class … category slugs do not have spaces in them, so this is incorrect. If you meant to have all upcoming and class categories, then use upcoming,class https://developer.wordpress.org/reference/classes/wp_query/#category-parameters You have a meta query on company but it sounds like you’re also … Read more