Tag Info

New answers tagged

0

I think you're looking for this... wp.getPosts({ status: 'trash', }, ['title','status'], function( err, data ) { console.log( data ); } });


0

After asking around and looking for alternatives, I came up with a working solution that works in the web frontend and in the Android/iOS XML-RPC based apps. This is the filter. add_filter('wp_insert_post_data', array($this, 'save_content2'), 9, 2); I am pretty sure it is called before the content_save_pre filter. It allows direct access to the post ...


0

Managed to figure it out in the end by modifying one of the core files of the plugin If you look in json-api/models/post.php there's a function set_content_value() which shows where the plugin is pulling in the content. Here you can modify it as needed, in my case I used it to remove certain shortcodes with the Wordpress remove_shortcode() function


0

When calling bp_loggedin_user_avatar(), you can set the 'html' attribute to false and it will return just the URL of the avatar (instead of the full HTML). Then you can style it how you want. Something like: $avatar_url = bp_loggedin_user_avatar( 'html=false' ); echo '<img class="media-object" src=' . $avatar_url . ' width="' . ...


0

Untested: function custom_home_exclude( $where = '' ) { $exclude = array(); $newsQuery = new WP_Query (array( "post_type" => "news", "meta_key" => "post_to_blog", "meta_value" => 1, "meta_compare" => "!=", "posts_per_page" => "-1", )); while ($newsQuery->have_posts()) ...


1

You don't need to create additional functions, just re-use what you already have and tweak it a bit: function theme_add_bootstrap() { wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/third_party/bootstrap/css/bootstrap.min.css' ); wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . ...


1

In short: WordPress uses the term count in various places. There's even another count that it's in the options table. So as long as you are talking about the core behavior, then the recommendation is: Never ever touch the WordPress cores term counting mechanism! It's hard enough to bring it to work in some cases (manually updating term stuff in very, ...


0

Maybe in the custom_rewrite function, try concatenating $wp_rewrite->rules and $feed_rules using array_merge, then returning $wp_rewrite. function custom_rewrite( $wp_rewrite ) { $feed_rules = array( 'local/(.*?)/(.*?)/?$' => 'index.php?page_id=41&trade=' . $wp_rewrite->preg_index(1).'&area=' . $wp_rewrite->preg_index(2), ...


1

This could be the matter of adjusting the priority of your filter callback, since the plugins files are executed before the functions.php theme file. That could explain why it works in your functions.php file, if the priority is the same. When you add the code snippet to a plugin, it might be executed before the other plugins that use the same filter. The ...


1

Your use of the_content filter is wrong. Please check how it should be properly used in the codex in the link supplied First of all you are totally replacing the_content with nothing, that is why you get a blank screen. The reason is that you are not calling the $content variable in your function Secondly, if you've called the variable, you would have ...


0

i didn't want to use js, i wanted a php solution, plus i also manipulate all internal links into anchor links. in the end, you have to decide for yourself, what would be the best way for you, php or js. this goes into functions.php inside the current theme folder. add_filter('the_content', 'crawl_content'); function crawl_content( $text ) { $url = ...


0

You could try using the terms_clauses filter function wpse156370_terms_clauses( $pieces, $taxonomies, $args ) { global $wpdb; $pieces['fields'] .= $wpdb->prepare( ', (SELECT COUNT(*) FROM ' . $wpdb->posts . ' p, ' . $wpdb->term_relationships . ' p_tr' . ' WHERE p_tr.object_id = p.ID AND p_tr.term_taxonomy_id = ...


0

The only way to do it is using a query filter I think function wpse156319_posts_where( $where, $query ) { global $wpdb; $where .= $wpdb->prepare( ' AND (' . $wpdb->posts . '.post_parent = %s OR ' . $wpdb->posts . '.post_author = %s)', $_POST['id'], get_current_user_id() ); return $where; } which you just add in the ...


0

This looks like it would get you pointed in the right direction: http://stackoverflow.com/questions/6215797/wordpress-post-id-in-wp-nav-menu


0

You can do this in jquery on document load. Using addClass $("#DivName").find("a").addClass("YourClassHere");


0

I doubt that ever worked by itself. WP_Query operates on posts database table. On the bottom SQL level to make use of post metadata you need to not only say what metadata you are looking for, but also instruct MySQL how metadata table connects to your posts table (JOIN realm). I would attempt to keep manipulating query arguments for starters, it doesn't ...


0

While there is no hook, there is a small workaround that makes your end-goal possible. You can create a new shortcode that, on a per-instance basis, you always wrap around any other shortcode whose output you want to filter. Usage in a post, etc: Here is some post text. Blah blah... [filter][target_annoying_shortcode size="small" limit="20"][/filter] Here ...


1

I always thought that the memory size was the limit for the string length, but according to the PHP documentation: string can be as large as up to 2GB (2147483647 bytes maximum) There is also the maximum allowed memory size (memory_limit) for the PHP script, to consider. Testing: Do not perform this on a production server: You could always use the ...


1

The $tag is used as a key in an array, so it is converted to either a string or an integer. There is no maximum size for strings, the available memory is the only real restriction. The size of an integer depends on the platform: The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits ...


0

The filter works when placed in active theme's functions.php file. Just tested that, and the result was positive.


0

In general they should. All of config load, plugins load, and theme load happens during load process and before init hook, which is considered a point after which load is done and functionality starts. Unless you are dealing with early load-related events, typically plugin is perfectly appropriate place. PS not sure what you mean by config.php, hooks don't ...



Top 50 recent answers are included