Tag Info

New answers tagged

-3

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh


0

I'd do it like this: $excluded_posts = array(); // select first 3 featured posts ordered by date $args = array ( 'post_type' => array( 'post' ), 'category_name' => 'featured', 'posts_per_page' => '3', 'order' => 'DESC', 'orderby' => 'date', ...


0

As explained in Codex post__not_in (array) - use post ids. Specify post NOT to retrieve. post__not_in argument have to be passed as array. Change your query to: $the_query = new WP_Query( array( 'category__in' => $project_category, 'posts_per_page' => -1, 'post__not_in' => array( $postid ), ) ); And it should work.


1

You're right. It isn't a good structure. You are running three queries on the page-- the two you are creating plus the main query that is being completely ignored (plus ancillary queries). You are also clobbering the main query halfway through the page load when you overwrite $wp_query, which can cause unexpected and unpredictable results and difficulty ...


1

We will use a small piece of the logic from my previous answer in this appraoch. We need to do the following: Get an array of post ID's from the query we have run to get our post limit of 100 Use the current post ID and search for that specific post ID in the array of post ID's Use the array key where our values match, add 1, and return that as our rank # ...


-1

After two days with this problem have resolved the problem, I fix it adding tax_query parameter with my taxonomy name and slug of the category requested: $args = array( 'post_type' => array ( 'servicios' => 'servicios', ), 'tax_query' => array( array( 'taxonomy' => 'category', ...


0

Try this, it may help: if( !defined( 'ABSPATH' ) ) exit; function modify_wp_search_where( $where ) { if( is_search() ) { global $wpdb, $wp; $where = preg_replace( "/($wpdb->posts.post_title (LIKE '%{$wp->query_vars['s']}%'))/i", "$0 OR ( $wpdb->postmeta.meta_value LIKE '%{$wp->query_vars['s']}%' ...


0

Don't use query_posts Create a new WP_Query or use pre_get_posts to modify an existing query. $args = array( 'post_type' => 'servicios', 'category_name' => 'category-name' ); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { echo '<ul>'; while ( $the_query->have_posts() ) { ...


-1

Just pass array with category terms in wp_set_post_terms taxonomy parameter. global $post; $post_id = $post->ID;//get the current post id $terms = array('term1','term2'); $taxonomy = 'category'; $append = false; // or true wp_set_post_terms( $post_id, $terms, $taxonomy, $append );


0

Finally! just install this plugin https://wordpress.org/plugins/linkify-tags/ then insert this script to theme <?php c2c_linkify_tags('24, 9, 33'); ?> and done!


0

I did something similar in the past project and this is my solution. I hope this is what you want. <ul class="inline-list"> <?php query_posts('category_name=lain-lain'); if (have_posts()) : while (have_posts()) : the_post(); if ( get_the_tag_list() ) : ...


0

I used the following in my child theme 'functions.php' to get posts by category name. You can also use category ID number but that didn't work for me. add_action('pre_get_posts', 'ad_filter_categories'); function ad_filter_categories($query) { if ($query->is_main_query() && is_home()) { $query->set('category_name','tips'); } }


0

If you're saving an array into Metadata it becomes Serialized. This makes it pretty difficult to query on, maybe try using wildcard: $args = array( 'ignore_sticky_posts'=> 1, 'post_type' => 'post_projects', 'meta_query' => array( array( 'key' => 'wpl_location', 'value' => '%Europe%', ...


0

You might be missing the 'meta_key' arg here: $args = array( 'ignore_sticky_posts'=> 1, 'meta_key' => 'wpl_location', // here 'post_type' => 'post_projects', 'meta_query' => array( array( 'key' => 'wpl_location', 'value' => 'Europe', 'compare' => 'IN', ), ), ...


0

From what I understand you have a loop that displays up to 500 pages. If the page parent = 18219 than you want to query the tags for that page. As far as I know, by default WP does not allow you to tag Pages, only Posts. But let's pretend you have a plugin that allows you to do that... Inside your loop you can check to see if the page has a parent equal to ...



Top 50 recent answers are included