Tag Info

New answers tagged

0

Try to delete from table a only Modified Query: DELETE a FROM wp_posts a LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id ) LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id ) LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id ) LEFT JOIN wp_terms e ON ( e.term_id = d.term_id ) WHERE e.term_id =1 AND DATEDIFF(NOW(), a.post_date) ...


0

It's not "smart" enough to reason that you want to modify the value, not just set it to something. You'll need to: retrieve the current value (get_query_var() probably) change it as needed use resulting value with add_query_arg()


0

You can't simply "merge categories" you have to change the category that each post is associated with. The table WP_TERM_RELATIONSHIPS links posts with categories. You could try something like this: UPDATE wp_term_relationships SET term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 112748) WHERE term_taxonomy_id = ...


1

An easy way is to use a static variable to store author name, then run again same function on a later hook, maybe 'posts_results' and set back the variable: function wpquery( $query, $query_on_results = NULL ) { static $author_name = NULL; if ( current_filter() === 'pre_get_posts' ) { if ( $query->is_author() && $query->is_main_query() ...


1

When the wp_enqueue_scripts action fires, the main query has already run and the posts are in the global $wp_query. We just need to grab the ID from each object in $wp_query->posts, the wp_list_pluck function makes that easy: function wpd_get_post_ids(){ if( is_archive() ){ global $wp_query; $post_ids = wp_list_pluck( ...


0

Try something like this : $value = get_field('field_name'); Try whole process based on this http://www.advancedcustomfields.com/resources/how-to/filter-posts-by-custom-fields/ $value = get_field('field_name', $category->cat_ID);


2

The issue is that there is no taxonomy meta data like there is for posts. ACF taxonomy data is stored serialized in the options table, so it can't be queried like post meta can. You have to load all terms and check the data associated to each one individually. Perhaps a better solution is to create Romance, Action, & Drama parent terms, and make your ...


0

If I understand you, I believe that the following will do what you need: function orderby_mod_wpse_140999($orderby) { remove_action('posts_orderby','orderby_mod_wpse_140999'); global $wpdb; return $orderby.", {$wpdb->posts}.post_modified DESC"; } add_filter('posts_orderby','orderby_mod_wpse_140999'); $args = array( 'meta_key' => 'premium', ...


0

You could force is_single when replacing the main query: $draft_post_query = new WP_query(array( 'post_status' => 'draft', 'post_type' => array('post'), 'post__in' => array($post_id) )); $draft_post = $draft_post_query->post; global $wp_query, $post; $wp_query = $draft_post_query; $post = $draft_post; $wp_query->is_single = true; ...


0

The "orderby" parameter takes a fallback value, and here you want to get the posts sorted by post date when the vote value is not available. so you can just append "date" to the orderby parameter like below to get the rest of the post in the loop sorted as per the dates:-- 'orderby' => 'meta_value_num date', For more details check the Codex


0

1) You can use the template search.php and searchform.php as your starting points. Creating a Search Page Codex 2) As far as the custom query goes, you can use pre_get_posts hook to test if you're on a search page, then you get $_GET your values, edit your query accordingly. Action Reference - pre_get_posts There are tons of tutorials online and questions ...


0

pre_get_posts pre_get_posts is used to alter the main query for posts so the is_home() conditional tag will work. You can also use the is_post_type_archive() conditional tag to alter the query on CPT archives like so. add_action( 'pre_get_posts', 'limit_cpt_items' ); function limit_cpt_items( $query ) { if( $query->is_main_query() && ...


0

The first way, using the pre_get_posts action will modify the main query before the page loads. The second way will create a new query. It is much better to alter the main query than to create a new query.


0

The error seems to be connected to the rss url itself, if I use 'http://seko.se/feed.rss?rssId=97' I can't create new loops beneath it but if I use another url such as 'http://www.wpbeginner.com/feed/' It works. My original feed works just fine in other readers so I have no idea why it does not work in wordpress.


0

I haven't tested this, but in my head it works perfectly! What we do is put add a pre_get_posts filter in our functions file then get the current user. IF user isn't registered, drop out. IF the number of user posts isn't greater than 0, drop out. IF we're not on the post type archive, drop out. IF all 3 conditions are true, we'll replace our default blog ...


1

By default hide_empty is true for get_terms. So i guess you must be missing terms which do not have posts. Try this, <?php $terms = get_terms("autorzy", array('orderby' => 'count', 'order' => 'DESC','hide_empty'=>0 )); $count = count($terms); if ( $count > 0 ){ echo "<div>"; foreach ( $terms as $term ) { ?> ...


0

Something like this should work but you haven't stated where you want to display the CPT pages for games. function display_games_archive( $query ) { if ( !is_admin() || $query->is_main_query() && is_post_type_archive( 'portcat' ) ) { $query->set( 'category__in', 'games' ); return; } } add_action( 'pre_get_posts', ...


1

What about using the UNION? Just an example: (SELECT * FROM $wpdb->posts (with JOIN and WHERE as needed)) UNION (SELECT * FROM $wpdb->posts (with WHERE to select pages)) GROUP BY/ORDER BY The select(s) must be in parenthesis to use an order by for the whole union result. As a second option, you can use a plugin to enable the categories and ...


0

You will need to join four table to get cateogries of custom post type "review" wp_term_relationships wp_posts wp_term_taxonomy wp_terms by using following query you can get list of categories applied to your custom post type: SELECT * FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON ...



Top 50 recent answers are included