Hot answers tagged

3

Because of this line: $paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1; This is inside a function that is used on both an AJAX handler, and on a page request. get_query_var pulls the parameters from the main query ( aka the primary WP_Query that powers functions such as the_post, have_posts() etc ). But this will never ...


1

Each pass through the foreach() loop, you're wiping out the values that are already in your $urls array. Try something like this: function rel_alternate_network(){ global $post; $slugX = is_main_site() ? $post->post_name : rtrim($post->post_name, '-in-'.strtolower(do_shortcode('[country]'))); $urls = array(); foreach(get_sites() as $...


1

This is my archive template — page-archive.php, which I am using as a template to display all my posts/recipes So if you're using a Page (post of the page type) with a custom/specific Page Template, then you should create a secondary query and loop for retrieving and displaying your recipes/posts. But even with a default archive template such as the archive....


1

You're reassigning 1 to $i on every loop: if ( $i = 1) { This should be if ( $i == 1) { or even if ( $i === 1) { which will also compare the post type, which is best practice. In PHP, = is assignment, == is comparison:


1

So i resolved that noob question... here is a recipe step by step; get some sleep repeat what you leaned with a fresh mind apply the structure: <?php if( get_field('field_name') ): ?> <p>My field value: <?php the_field('field_name'); ?></p> <?php endif; ?>


1

The category object stores the parent ID like this: $category->parent In the event that there is no parent it's equal to 0. In this way, it is possible to create a variable equal to the parent class or the child parent according to the value of $category->parent: $categories = get_categories(); if ( ! is_wp_error( $categories ) ) { foreach ( $...


Only top voted, non community-wiki answers of a minimum length are eligible