Ciao, dovrei inserire anche il valore '1' oltre allo '0' in value...come fare? grazie
Codice PHP:
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
Ciao, dovrei inserire anche il valore '1' oltre allo '0' in value...come fare? grazie
Codice PHP:
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
Non puoi avere 2 chiavi con lo stesso nome, devi trovare un sistema diverso per memorizzare il dato.
Grazie, questo è il codice:
Codice PHP:
<?php
$args = array(
'post_type' => $taxonomy_profile_url,
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
);
$normal_profiles = new WP_Query( $args );
$i = "1";
if ($normal_profiles->have_posts()) :
while ( $normal_profiles->have_posts() ) : $normal_profiles->the_post();
include (get_template_directory() . '/loop-show-profile.php');
endwhile;
else:
_de('No %s here yet',29,$taxonomy_profile_name_plural);
endif;
wp_reset_postdata();
?>
Ho provato così ma nulla:
Codice PHP:
<?php
$args = array(
'post_type' => $taxonomy_profile_url,
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
);
$premium_args = array(
'post_type' => $taxonomy_profile_url,
'meta_query' => array( array('key' => 'premium', 'value' => '1', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
);
$normal_profiles = new WP_Query( $args ); $normal_profiles = new WP_Query( $premium_args );
$i = "1";
if ($normal_profiles->have_posts()) :
while ( $normal_profiles->have_posts() ) : $normal_profiles->the_post();
include (get_template_directory() . '/loop-show-profile.php');
endwhile;
else:
_de('No %s here yet',29,$taxonomy_profile_name_plural);
endif;
wp_reset_postdata();
?>
Cosa sbaglio?
Ultima modifica di Lino80; 21-12-2019 a 11:11
Da quel codice lì capisco che stai modificando o scrivendo un qualche plugin per WordPress per prendere dei post, ma poi chiedi solo "cosa sbaglio?".
Dovresti anche dire cosa vorresti che facesse e invece cosa ottieni.
Si tema wordpress.
'value' => '0' mi stampa i valori dove premium è = a 0
'value' => '1' mi stampa quelli dove è = a 1
vorrei che mi stampasse entrambi i valori di 'premium' = 0 e 1
Ho provato così ma nulla:
vado a tentativi non essendo programmatoreCodice PHP:
$args = array(
'post_type' => $taxonomy_profile_url,
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
); $args2 = array(
'meta_query' => array( array('key' => 'premium', 'value' => '1', 'compare' => '=', 'type' => 'NUMERIC') ),
);
$normal_profiles = new WP_Query($args, $args2);
così dovrebbe funzionare ma mi restituisce i post del blog e non gli utenti
Codice PHP:
<?php
$args = array(
'post_type' => $taxonomy_profile_url,
'post__in' => $r,
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
);
$args2 = array(
'post_type' => $taxonomy_profile_url,
'post__in' => $r,
'meta_query' => array( array('key' => 'premium', 'value' => '1', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
);
$ids = array_merge($args->posts, $args2->posts);
$normal_profiles = new WP_Query(array('post__in' => $ids,'orderby' => 'post__in'));
$i = "1";
if ($normal_profiles->have_posts()) :
while ( $normal_profiles->have_posts() ) : $normal_profiles->the_post();
include (get_template_directory() . '/loop-show-profile.php');
endwhile;
else:
_de('No %s here yet',29,$taxonomy_profile_name_plural);
endif;
wp_reset_postdata();
?>
Codice PHP:
<?php
$args = array(
'post_type' => $taxonomy_profile_url, 'post__in' => $r,
'meta_query' => array( array('key' => 'premium', 'value' => '0', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
); $premium = new WP_Query( $args ); $premium_found_posts = $premium->found_posts; $args2 = array(
'post_type' => $taxonomy_profile_url, 'post__in' => $r,
'meta_query' => array( array('key' => 'premium', 'value' => '1', 'compare' => '=', 'type' => 'NUMERIC') ),
'posts_per_page' => get_option("frontpageshownormalcols") * 5
); $normal = new WP_Query( $args2 ); $premium_found_posts = $normal->found_posts; $all = $premium;
$q = array_merge($premium->posts, $normal->posts);
$all->posts = $q;
$i = "1";
if ( $all->have_posts() ) : while ( $all->have_posts() ) : $all->the_post();
include (get_template_directory() . '/loop-show-profile.php');
endwhile;
else:
_de('No %s here yet',29,$taxonomy_profile_name_plural);
endif;
wp_reset_postdata();
?>
così credo che vada bene.......ma........mi da errore: mod_fcgid: stderr: PHP Warning: array_unique() expects parameter 1 to be array, null given in /web/htdocs1/dom/home/www/wp-includes/post-template.php on line 834
riga 834:Codice PHP:
function wp_link_pages( $args = '' ) {
global $page, $numpages, $multipage, $more;
Risolto con sistema diverso come dicevi tu Alhazred
Semplicemente inserendo 'key' => 'altrovalore', buone feste