Concatenate string to the_field()

You’ll have to show more of the relevant code, but, to begin with, if you want to check for the availability of a ‘preparation_time’ ACF value, use if ( get_field( ‘preparation_time’ ) ) : // get_field(), not the_field() As the ACF docs put it, the_field( ‘field’ ) is the same as echo get_field( ‘field’ ) … Read more

Highlight the links without using dropdown

SOLUTION I found it by using the <?php wp_list_pages( $args ); ?> with customizing the args to display only selected children by id. $args = array ( ‘title_li’ => ”, ‘child_of’ => $post->ID, ‘include’ => 47 ) <h4> <?php wp_list_pages( $args ); ?> </h4> and setting the css to target the current and its parent … Read more

Adding function to child theme’s function.php

You can’t recall the same function or PHP will throw an error. Make your own function and call the same action hook, but give it a priority of 1 which should overrule the parent theme function. function custom_oblique_post_link_to_single() { if ( ! get_theme_mod( ‘read_more’ ) ) :?> <a href=”https://wordpress.stackexchange.com/questions/282703/<?php the_permalink(); ?>”> <div class=”read-more”> <?php echo … Read more

Refactoring long if/else php chains

There is no hard limit, but when you have many fields (I’m talking hundreds or thousands, not dozens), you might run into limits on execution time on your host. In this case, I’d do something like this to turn it into a loop if you don’t need specific HTML. foreach(range(1, 5, 1) as $imageNumber) { … Read more

Api external with wordpress

WordPress itself can communicate with external API’s through wp_remote_get and wp_remote_post. See the codex. In your case, you could create a page template called page-search.php (keep in mind that search.php is reserved for the internal WordPress search functionality, so you would define it as a template, and select it when creating the page), and run … Read more

Returning all values from foreach in function php [closed]

Try this: function returncartdata($data) { $return = ”; foreach ($data as $carthtml => $itemhtml) { $return .= $itemhtml[0]; $return .= $itemhtml[1]; $return .= $itemhtml[2]; $return .= $itemhtml[3]; $return .= $itemhtml[4]; } return $return; } $rawhtmlcartdata = cart_items_array(); $ordercart = returncartdata($rawhtmlcartdata); wp_insert_post(array ( ‘post_type’ => ‘saved-orders’, ‘post_title’ => ‘Test’, ‘post_content’ => $ordercart, ‘post_status’ => ‘publish’, ‘comment_status’ … Read more