Why does this echo values in the wrong order?

As most template tags that start with the_ this one echoes time and not returns it (which template tags that start with get_the_ do). First the_time() fires and echoes year, then its return (null) gets concatenated and echoed with string. So: echo ‘Archive for ‘; the_time(‘Y’); Or: echo ‘Archive for ‘ . get_the_time(‘Y’);

Replacing mysql_real_escape_string in WordPress theme

As mysql_real_escape_string() was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0, you can try esc_sql() to work for later WP/PHP versions. Replace mysql_real_escape_string() with esc_sql() at line 111 & 118 in your admin-interface.php file. Hope this should work well for you!

Getting the Current User

Call the function get_currentuserinfo() on the next line after declaring the global variable $current_user What is the difference between wp_get_current_user() and get_currentuserinfo()? Below is a snippet: function wp_get_current_user() { global $current_user; get_currentuserinfo(); return $current_user; } I think the source code answers your first two questions, right? Remember that wp_get_current_user() is defined in wp-includes/pluggable.php so it … Read more

WordPress Custom Page Template in a different directory

WordPress uses get_page_template() to determine the template file to use which can be altered by filters: //for pages add_filter( ‘page_template’, ‘My_custom_page_template’ ); function My_custom_page_template( $page_template ) { if ( is_page( ‘my-custom-page-slug’ ) ) { $page_template=”pathto/custom-page-template.php”; } return $page_template; } //for posts add_filter( ‘single_template’, ‘My_custom_page_template’ ); function My_custom_page_template( $single_template ) { if ( is_single( ‘my-custom-page-slug’ ) … Read more

Using Cookie Data For WP_Query Loop

You need to explode the comma separated string to get the array of IDs. Follow the below code. $cookie_array = $_COOKIE[“your-results”]; // Test output echo $cookie_array; $cookie_array = array_map( ‘absint’, (array) explode(‘,’, $cookie_array) ); $sug_args = array( ‘post_type’ => ‘product’, ‘post__in’ => $cookie_array, ); $sug_query = new WP_query ($sug_args); if( $sug_query->have_posts() ) : while( $sug_query->have_posts() … Read more

How to load WP functions?

The root problem here is that you should never make direct requests to PHP files in a theme or plugins from the browser. It is extreme bad practice, fragile, and open to lots of security issues. To get this working as is you would need to bootstrap WordPress by putting something similar this near the … Read more

Display only text to WordPress loop without loosing the text formatting

Try this code in your theme’s functions.php file- function filtered_content($content){ $content = preg_replace(“/<img[^>]+\>/i”, “”, $content); // removes images $content = preg_replace(‘/<iframe.*?>/’, “”, $content); // removes iframes return $content; } add_filter(‘the_content’, ‘filtered_content’); This will remove img and iframe tag from your content. Then use the_content() in your template.

Limit the Excerpt field in WP-Admin in words

You can use something like jQuery Simply Countable plugin and attach it to excerpt input. Limit_Excerpt_Words::on_load(); class Limit_Excerpt_Words { static function on_load() { add_action( ‘admin_enqueue_scripts’, array( __CLASS__, ‘admin_enqueue_scripts’ ) ); } static function admin_enqueue_scripts() { global $hook_suffix; if ( ‘post.php’ == $hook_suffix || ‘post-new.php’ == $hook_suffix ) { wp_enqueue_script( ‘jquery-simply-countable’, plugins_url( ‘/jquery.simplyCountable.js’, __FILE__ ), array( … Read more

Copyright info change in Theme Child PHP

You need to modify 2 functions not only 1 in your functions.php: /** * Function to display footer content. * * @since 1.1.24 * @access public */ //ADDED CHILD TO THE END OF THE NAME function hestia_the_footer_content_child() { /** * Array holding all registered footer widgets areas */ $hestia_footer_widgets_ids = array( ‘footer-one-widgets’, ‘footer-two-widgets’, ‘footer-three-widgets’ ); … Read more