engelen
  • Member for 8 years, 3 months
  • Last seen more than a week ago
Query custom post type by custom taxonomy (category slug)
Accepted answer
1 votes

Edited to reflect question in OP's comment. The contents of the tax_query array are not exactly right: as you're querying by slug, the field parameter of the individual taxonomy query should be "...

View answer
How can I comment comma-separated array values?
Accepted answer
1 votes

No, it's definitely not okay to comment your code this way. It changes the string, and even though WordPress might strip the incorrect characters and yield the correct pages (it wouldn't if your "...

View answer
How to get all taxonomies which can be added in menu?
Accepted answer
0 votes

The taxonomies visible in the admin menu are exactly those taxonomies that were registered with show_in_menu = true and show_ui = true. For a reference on this, see the documentation on ...

View answer
How to query posts of standard post format. For real
7 votes

Since WordPress 4.1, WP_Tax_Query supports the NOT EXISTS operator for taxonomy queries. As a post has the "Standard" format if and only if it has no specified format, this is now the preferred method ...

View answer
Form action unfamiliar
Accepted answer
2 votes

Generally, they will return the same URL, as bloginfo( 'url' ) will call home_url internally with any arguments, and the default first argument ($path) of home_url is the empty string. However, ...

View answer
wp_kses vs wp_strip_all_tags
3 votes

I wouldn't call it a benefit or disadvantage, but more of a difference: wp_strip_all_tags simply strips all tags (except for the allowed tags) but does not delete their content by calling the PHP ...

View answer
Fatal error: Call to undefined function the_posts_navigation()
Accepted answer
2 votes

The function the_posts_navigation() was added in WordPress 4.1.0, and will therefore not be available in version 4.0 (which you're using). It's highly advised to keep up to date with the latest ...

View answer
get_title without filter(the_title)
Accepted answer
3 votes

There's a few ways to do this, but I would argue that the preferred way is, in general, fetching the post_title attribute from the post object. This does not depend on removing all filters for a ...

View answer
Custom bulk_action
Accepted answer
3 votes

I think the latest major release warrants a new answer to this question, considering the popularity of this question. Since WordPress 4.7 (released December 2016) it is possible to add custom bulk ...

View answer
Use has_filter on comment_post
Accepted answer
1 votes

You're adding the action on comment_form_before_fields in comment_form_logged_in_after. The latter is called only when the user is logged in, and the former is only called when the user is not logged ...

View answer
Cannot access elements of json object
Accepted answer
2 votes

The result that is currently returned is raw text, which means data[0] accesses the first element (i.e. character) of the string, which is {. Obviously, you want to turn the returned data into a JSON ...

View answer
How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
3 votes

There is no good filter to add the CSS classes to the anchor (<a>) elements, but as you need it for CSS styling you can use the filter for the <li> elements. This filter is called ...

View answer
How order posts from category by date and comment count?
Accepted answer
1 votes

The query you currently have will order the posts by their post_date property, which is an SQL column of the type datetime. This type stores the date, but also the time (hours, minutes and seconds). ...

View answer
How to generate "og:image" meta for Facebook sharing when the image in the post is not featured?
Accepted answer
4 votes

As was already stated, Facebook automatically detects images if the OG image tag is missing. However, in some cases, it might detect other images (e.g. not from your post but from other content). In ...

View answer
Correct (and secure) way to escape url when using href attribute
Accepted answer
0 votes

The use of escaping data before outputting it to the browser ensures that no malicious (external) content (over which you have no control) can be outputted to the browser, and that no errors occur in ...

View answer
Wordpress matching URLs with trailing tildes
3 votes

Let me explain WordPress' processing of a request, and a method to change WordPress' behaviour to accomplish your goals accordingly. Parsing the request When WordPress receives a request, it starts ...

View answer
Creating widget - ask for selecting a post in the admin panel
0 votes

First off, try to work on your code formatting. As it is, it's rather unreadable and this makes it not only more difficult for us to understand how to help you, but also less scalable and suited for ...

View answer
List users of specific role instead of removing them with specific role
Accepted answer
0 votes

To fetch users from a specific role, you can use the role parameter of the get_users function. Each role has a specific ID; for WordPress' native roles, these are administrator, editor, author, ...

View answer
Change Woocommerce languange on a multisite install
Accepted answer
1 votes

For WooCommerce to support any language other than the default (US English), you have to make sure of the following — it doesn't matter whether you're on a multisite or single-site install: In the ...

View answer
Creating an admin meta box to save post as pending
Accepted answer
1 votes

The reason your code does not work is that the if-statement checking isset( $_POST['wp_cfc_save_meta_box']) never evaluates to true. Your code generating the submit button, <?php submit_button( __(...

View answer
Unable To Get Published posts using query_posts
Accepted answer
2 votes

First off, you probably shouldn't be using query_posts, which modifies WordPress' main loop and is unsuited for pretty much any purpose (read When should you use WP_Query vs query_posts() vs get_posts(...

View answer
Plugin Options Array Set to Undefined
Accepted answer
2 votes

WordPress provides a default method, wp_parse_args, to combine a set of default options and a user-defined set of options. This method uses PHP's native array_merge for arrays, but also works when ...

View answer
Why use wp_send_json() over echo json_encode()?
Accepted answer
24 votes

wp_send_json() handles all parts of returning content in an AJAX call. First off, it sets the content type of the returned content to application/json with the proper charset. Secondly, it ...

View answer
Is there a way to dump all registered sidebar/widget?
1 votes

There is, in fact! The global variable $wp_registered_sidebars stores the registered sidebars, and $wp_registered_widgets stores all registered widgets (by widget ID).

View answer
Change Spaces to Dashes?
Accepted answer
1 votes

You could simply use str_replace: str_replace( ' ', '-', $name ) In your code, this would translate to: return '<img src="/images/flags/' . str_replace( ' ', '-', $name ) . '.gif" alt="' . $...

View answer
How to hook into the quick edit action?
0 votes

save_post is actually called on saving a post through the Quick Edit feature as well. As we find from the source code, the save_post action is called from two functions: wp_publish_post and ...

View answer
How to display posts from multiple post type in random order in wordpress?
1 votes

You would need two queries to achieve this. You can't specify the limit per post type in WP_Query (without modifying the raw SQL). What you could do is simply query the posts and the photos and merge ...

View answer
Sorting by meta_key different to search criteria?
Accepted answer
1 votes

The value for the value key in the meta query is probably the cause of the problem. 'value' => get_post_meta( get_the_ID(), 'cancelled', true ) The get_post_meta call actually retrieves the ...

View answer
Is it possible to get feature image url (full-size) from an image url of smaller size?
Accepted answer
1 votes

The URL for rezied images in WordPress is constructed in a way that's impossible to direct reverse. Therefore, it's impossible to get the attachment associated with a URL of a resized image with 100% ...

View answer
Wordpress registration page template
Accepted answer
1 votes

WordPress has no default form or way to create custom registration and login pages. However, it is quite possible to do all this yourself! I'll try to get you started: 1. Page Templates WordPress ...

View answer