Tag Info

New answers tagged

2

When there are no posts, there is no post ID for get_field_object to operate with. If you read the docs for that function, you'll see: $post_id Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc


3

Ignore my comment about meta_query. Not only does it not work with $query->set(), you wouldn't be able to control the critical "A OR B" requirement of the query. Instead, I believe what you require is possible via a combination of both the pre_get_posts action hook and posts_where filter hook as follows. add_action('pre_get_posts', ...


1

You can set tax query in pre_get_posts hook as well: $query->set('tax_query', array(__standart parameters__));


1

You cannot do this with the default paginate_links() functions. Looking at the source code, there are no filters from which you can change the layout as you wish ALTERNATIVE SOLUTIONS Although you cannot do this by default, it doesn't mean that you cannot get your desired output. Here is a couple of options to explore OPTION 1 Write a wrapper function ...


0

After a lot of messing around with this, I think I found a fairly good solution here. I realize this is over a year after you asked but this was bothering me and I couldn't find a good solution until now. The problem is that the get_post_metadata function doesn't allow you to access the current value. This means you aren't able to transform the value, just ...


1

You are using array_push() incorrectly. Do this: $classes[] = 'new-class'; Or this: array_push( $classes, 'new-class' ); But not: $classes[] = array_push( $classes, 'new-class' );


1

Adding a NOT EXISTS clause should force LEFT JOINs: 'meta_query' => array( 'relation' => 'OR', array('key' => 'file_gallery', 'value' => '1', 'compare' => '!='), array('key' => 'file_gallery', 'compare' => 'NOT EXISTS'), ),


1

If anyone should be faced with this problem, check if you have defined a callback function to set the user_login on pre_user_login. This filter is applied inside the wp_insert_user()-function and produced a same username again. Therefore the nicename was changed by adding a "-2". So, my problem was that I reset the user_logins again and again, instead of ...


0

If you use do_action( 'woo_collections_menu' ); in the template, then your function must echo its value. Otherwise, you are returning the data into a black hole, nothing is outputting what you're returning. If you use a filter, then you should return the value. The point of a filter is to take a value, filter that value through a function, then do something ...


0

I still couldn't figure out how to return $woo_menu; with my first example code, but I realized things don't break if I keep the rest of the structure as far as the variable goes and just echo once at the very end. This seems to work for me. Whether this is good practice or not, leave me a comment, but for now, this is the solution I'm using. Thanks. ...


1

From my understanding of actions (as opposed to filters), an action simply does something and stops processing. No return value is actually made use of. You might change your code to be a filter by accepting an argument (say the html to append to) and then make a call like the following where you want to grab the code: $html_block = ...


1

get_current_screen() is a pain, I use the following code to avoid/wrap it: /* * Convenience function to tell if we're on a specified page. */ function theme_is_current_screen( $base = null, $post_type = null ) { if ( ! $base && ! $post_type ) { return false; } $screen = function_exists( 'get_current_screen' ) ? ...


1

According with the codex, get_current_screen() has to be used later than admin_init hook. After a few tests, it seems that the safiest way is to use current_screen action hook instead of get_current_screen(): add_action('current_screen', 'current_screen_callback'); function current_screen_callback($screen) { if( is_object($screen) && ...


2

You can try the image_send_to_editor filter: /** * Wrap the inserted image html with <figure> * if the theme supports html5 and the current image has no caption: */ add_filter( 'image_send_to_editor', function( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if( current_theme_supports( 'html5' ) && ! ...


2

QUESTION AND ANSWER REVISITED There are sometimes these questions that nags you and hunts you down later in life again, and this is one such question. This question had me thinking about an alternative solution to the problem. As I already stated, custom fields and meta boxes are there to store small pieces of meta data, and not to act as an extension to ...



Top 50 recent answers are included