What code to use in an array to call the current sub-category?
You shouldn’t be using WP_Query at all. The standard loop will automatically display the correct posts. while ( have_posts() ) : the_post(); endwhile;
You shouldn’t be using WP_Query at all. The standard loop will automatically display the correct posts. while ( have_posts() ) : the_post(); endwhile;
Ok solved it like this : <?php $mainquery = get_queried_object(); $args = array( ‘pagename’ => ‘Accueil’ //as my home page ); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div class=”entry-content”> <?php the_content(); // here I can load my content ?> </div><br><br> <?php } } wp_reset_postdata(); global $wp_query; $args = array_merge($wp_query->query, … Read more
I would like to replace those arrays with real values. Is it possible? I am assuming you want to access and print those two variables which is shown as “Array” in the print out (contact, question_answers_array) Solution as follows – replace your foreach look with below (I didn’t test code but should give you an … Read more
How do i fix this “call_user_func_array()” error
Try this <?php if ($args[‘avatar_size’] != 0) echo get_avatar($comment,’70’,$default, $alt,array(‘class’=>array(‘media-object’,’thumbnail’))); ?>
I can’t comment due to lack of reputation, so I’ll address the issue rudtek mentioned. Personally, I never came across a host that disables PHP’s rand() function, but in case there is such a lousy host, you can opt for a more efficient way of doing things. What you can do is to get all … Read more
WordPress Settings API Overrides My Previous Value
That is not an accepted SQL syntax per the MySQL manual. You must INSERT INTO MyGuests (firstname, lastname, email) VALUES (‘John’, ‘Doe’, ‘[email protected]’) But, and this is an expansion well beyond the scope of your question, if you have an array of this information, you could iterate over the whole thing to build your SQL … Read more
If we look at the official documentation, this is how wp_set_object_terms is used: wp_set_object_terms( int $object_id, string|int|array $terms, string $taxonomy, bool $append = false ) Notice the final parameter that isn’t being used in your code, it has a default value of false: bool $append = false ) So everytime your loop runs, it wipes … Read more
to get pages as array use get_pages() instead. now once we have a list we can check the size of list and split it. Let’s have an example: $allpages = get_pages( array( ‘child_of’ => $section_top_parent, ‘post_type’ => ‘section’, ‘depth’ => 1, ‘sort_order’ => ‘asc’ ) ); //check $allpages has any value if($allpages){ //calculate the array … Read more