Live search from database table

So in php it needs to be: $query = ‘SELECT Location FROM locations’; $result = mysqli_query($link, $query); $rows = array(); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r[‘Location’]; } and jquery ui autocomplete: $(“#location1”).autocomplete({ source: <?php echo json_encode($rows);?>, // this part is only if you want to force autocomplete select change: function (event, ui) { if(!ui.item){ … Read more

Search only working on front page (index) , not working on other pages

Currently your form looks like: <form id=”search-query”> <p class=”in-english”><a href=”http://localhost/hermodswp/?page_id=76″>Information in English</a></p> <div class=”search-box”> <div> <label class=”screen-reader-text” for=”s”></label> <input type=”text” value=”sdf” name=”s” id=”s” style=”width: 293px;”> <input type=”submit” id=”searchsubmit” value=”Sök”> </div> </div> </form> Try adjusting your submit action to point to your home_url(). action=”<?php echo home_url(); ?>” You can edit the page in Chrome to see … Read more

PHP Output also in Child theme, but different

You need to make the function pluggable, that means, to support child themes, the functions in parent theme should use: if ( !function_exists( ‘function_name’ )) { function function_name() { //Stuffs } } You should have seen a PHP Error message if you have debugging enabled. EDIT: The below code snippet if to answer your other … Read more

How to use functions [closed]

To answer your question, the current method would be to create the object then call the method: $objClassName = new ClassName(); $var = $objClassName->updateRegularBalance(5); Another way would be to make the method static since the class has no private data(In your case) to rely on: public static function updateRegularBalance($amount){} This can then be called like … Read more

php – Plugin/theme relative PATH/URI

Just don’t do it, you can never know if the plugins directory is even “below” ABSPATH, and you can not know the URL out of the directory path https://codex.wordpress.org/Determining_Plugin_and_Content_Directories. Just use the core api of plugins_utl etc, don’t reinvent the wheel.

Link to page with posts of specific type

First, never use query_posts, use WP_Query to create additional queries. When you register your post type, set has_archive to true, or a string which will be the URL slug for your post type archive. You can then use get_post_type_archive_link() to output the URL to your post type archive. <a href=”https://wordpress.stackexchange.com/questions/210453/<?php echo get_post_type_archive_link(“issues’ ); ?>”><li>View All</li></a>

Custom pagination (Previous / Next)

Well… pretty much just do exactly what you said. Add a class conditionally based on the number of links O.o $link_container_class=””; if (!empty($links)) { if( 1 === count( $links ) ) { $link_container_class=”single”; } ?> <nav class=”post-nav clear clearfix <?php echo $link_container_class; ?>”> <ul><?php echo implode($links); ?> </ul> </nav><?php } ?>