add the value of a variable returned in a while loop [closed]

Try to change with this: …….. …….. …….. $fullcost = 0; while( $connected->have_posts() ) : $connected->the_post(); $cost = get_post_meta( $post->ID, ‘foxware-ingredient-cost’, true ); $fullcost += $cost; echo ‘<li>’; the_title(); // Display cost echo ‘<br>’; echo ‘Cost: ‘ . $cost; echo ‘</li>’; endwhile; echo $fullcost; ?>

Deeper editing of index.php and single.php

hey add the following code in your index.php file to show the three recent blog post like this <?php query_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘order’ => ‘ASC’, )); ?> <?php if ( have_posts() ) :?> <?php while ( have_posts() ) :the_post(); ?> <!– Start BlogItem –> <article id=”post-<?php the_ID();?>” <?php post_class();?>> <?php the_post_thumbnail( …

Read more

Call featured image url

the_post_thumbnail() is highest level function for it, which will output complete HTML. If you need some lower level parts, digging deeper are nested: get_the_post_thumbnail() wp_get_attachment_image() wp_get_attachment_image_src()

WPDB secure custom form

When getting user input to be stored on database, a good way to proceed is: Data validation: validate the data according whith the data you expect. For example: HTML string, number, email, URL, any text with no HTML, ect. Never trust on user input or client-side validation. You can make here also some sanitization, but …

Read more

Nav-Menu not showing up

To see the menu, you need to set it up in the wordpress admin side. Go to Appearance -> Menus You should see a “Manage Locations” tab. Select it. You should see your “Main Menu” location. Choose the menu that you created there. Select Save Changes. Since you used “theme-location” to set up drawing it, …

Read more

Only load certain artists on this page

if you want to show only 2, put it as a value, like so: ‘posts_per_page’ => 2 For the newest posts, you need to change the sort using the order and orderby params: ‘orderby’ => ‘date’, ‘order’ => ‘ASC’ Details about orderby params here: Also, you should avoid the query_posts use. Except if you …

Read more

How to Display a List of Child Pages For a Parent Page in WordPress

you can use post_status. post_status A comma-separated list of post status types that should be included. For example, ‘publish,private’. possible values are: (publish|inherit|pending|private|future|draft|trash) or you can also play with: include Only include certain Pages in the list generated by wp_list_pages. This parameter takes a comma-separated list of Page IDs. more about it here..