engelen
  • Member for 8 years, 3 months
  • Last seen more than a week ago
Difference between get_category, get_term_by and get_categories
2 votes

First of all get_categories retrieves a list of categories, and it shouldn't be used for fetching a single category by ID. The different between get_term_by and get_category is that get_term_by ...

View answer
How to make javascript work on theme options page
Accepted answer
2 votes

The problem with your code is, as we found out in the comments on the question, that you're using $, which is either undefined or has a conflict (in any case, it's not pointing to jQuery). Using ...

View answer
WP query exclude post within the last month / only show over 1 month old
Accepted answer
2 votes

The date query for WP_Query supports several options, including before and after. Using just before, you can fetch posts from before a certain date (excluding posts from that date on): $args = array( ...

View answer
store custom WP table names in a global variable
Accepted answer
2 votes

The DB_ constant prefix in WordPress is generally considered reserved for DB_NAME, DB_HOST, DB_USER and DB_PASS. Using it for plugin-specific constants is, in my opinion, not a great idea. The only ...

View answer
Extend Screen Options
Accepted answer
2 votes

To change or extend the functionality of WordPress Core, WordPress relies heavily on actions and filters. I'll assume you have basic knowledge of this, and if you don't, you will after reading up on ...

View answer
List Categories of the Parent Category of the Current Category
Accepted answer
2 votes

Assuming you have only two levels of categories, you could first retrieve the parent category and then list the child categories. Furthermore, calling get_children and wp_list_categories uses more ...

View answer
How can I determine what mode the editor is in and when it changes?
Accepted answer
2 votes

To determine what mode the editor is currently in, you can use the getUserSetting('editor') in JavaScript, which returns either "html" or "tinymce". To determine when the editor mode is switched, you ...

View answer
Getting author page slug from get_users() or get_userdata() functions
2 votes

You can retrieve the author page URL for any user by their user ID using the WordPress native function get_author_posts_url(). Combining this with get_users() to retrieve an array of users, you can ...

View answer
How to read a page's "Shortcodes" from the Template File?
2 votes

Parsing shortcodes from strings WordPress parses and replaces shortcodes from a piece of content via the do_shortcode function. This function, in turn, calls get_shortcode_regex, which returns the ...

View answer
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
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
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
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
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 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
WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post
Accepted answer
1 votes

The nonce field is not added to the form, and is therefore not passed in the POST request when submitting the form. Thus, isset( $_POST['post_nonce_field'] ) returns false and the conditional is never ...

View answer
Instance not inserting data for widget
Accepted answer
1 votes

You're using get_field_id in the name attribute of the "limit" field, where you should be using get_field_name. You're actually using get_field_name for the name attributes of the other two fields. ...

View answer
Permalink remain the same on each page
1 votes

First of all, don't use query_posts; use a WP_Query object instead. The reason your links are not being displayed correctly is that the link (<a> tag) is not actually within the loop. <?php ...

View answer
Wordpress Media Manager 3.5 - default link to
1 votes

I know this is an old question, but I believe this answer is better suited now, as WordPress does now allow you to hook into this. The default image size, align and "link to" properties for inserting ...

View answer
Adding more onto an esc_url
Accepted answer
1 votes

To concatenate strings, PHP uses the concatenation operator .. Thus, to append a string to the current user link, you can use bp_core_get_userlink( get_the_author_meta( 'ID' ), false, true ) . '/...

View answer
Change RSS format for specific categories
Accepted answer
1 votes

It certainly is! WordPress has filters called the_excerpt_rss and the_content_feed which filter the posts' content and excerpts for the RSS feed. The filter is called in the loop, so you can use ...

View answer
Using a custom field value as current users name
Accepted answer
1 votes

First of all, you're testing for a string, as you're wrapping the_field("my_field") in single quotes. So, you want to remove these quotes. Next, the_field("my_field") outputs a field, it doesn't ...

View answer
Create Pop-Up Box with Custom Field Content Inside the Loop
1 votes

The problem is that you're not assigning a unique ID to each popup element. HTML element IDs should be unique, and each time you call animatedcollapse.show( 'script-sample' ) it will target the first ...

View answer
Capitalize Shortcode Value on Output
1 votes

You can use preg_replace_callback for this. It uses regular expressions to replace part of a string. Using the regular expression "-[a-z]" matches a dash followed by a lowercase letter. Adding ...

View answer