How to split the loop every 2 and 5 results? [closed]

Yes you can do that using $wp_query->current_post inside the loop. It returns the current posts index number inside the loop (starting form 0). Have a look at the following code block <?php global $wp_query; while(have_posts()){ the_post(); the_title(); //do your other stuff if($wp_query->current_post==1){ //do what you want to do after 2nd post }else if($wp_query->current_post==5){ //do what … Read more

How to store wordpress title in a variable

You’re example is totally unclear. What is ngegrab, what is $unity, $yesPage and what do you mean with “WordPress title”? Short: what are you trying to do exactly? To get the title of a post, use get_the_title() as mentioned in the other answer. To get the document title (<title></title>), use wp_get_document_title().

WordPress Not Sorting By Custom Field

Please read the documentation. ‘rating’ is not a valid value for orderby. To sort by a custom field you need to use ‘orderby’ => ‘meta_value’ or ‘meta_value_num’. Note that a ‘meta_key=keyname‘ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can … Read more

Loop that displays all posts by logged in user, with Post Edit link

$posts = get_posts( array( ‘post_author’ => get_current_user_id(), ‘post_status’ => ‘any’, ‘post_type’ => ‘any’, ) ); foreach ( $posts as $post ) printf( ‘<a href=”https://wordpress.stackexchange.com/questions/103977/%s”>%s</a><br />’, esc_attr( add_query_arg( ‘_ninja_forms_action’, ‘edit’, get_permalink( $post ) ) ), get_the_title( $post ) );

Undefined variable: woocommerce_loop [closed]

As you have updated WooCommerce to latest version, templates you have in your theme must have gone outdated. (Not sure which previous version you had on your website before updating it to latest version). Please check WP Admin -> WooCommerce -> System Status -> at bottom there will be section named “Templates” there you can … Read more

Display all posts in a page code for template

That’s because the code you listed only includes a reference for the title and the link. Here’s your original code, annotated … Original <?php $debut = 0; //The first article to be displayed ?> <?php while(have_posts()) : the_post(); ?> <!– Display the title of the current page that’s listing your posts –> <h2><?php the_title(); ?></h2> … Read more