You may encounter the following error messages in Site Health for a WordPress Docker container if not using port 80 Fix either by mapping port 80:80 for the container or changing the WordPress home and URL addresses to the host machine IP instead of localhost.
Tag: wordpress
Woocommerce Update All Products With New Download Limit
Run the following MySql query to generate the new download limit of 100 for all Woocommerce products in WordPress. UPDATE wp_postmeta SET meta_value = “100” WHERE meta_key = “_download_limit”
Proxy Settings for WordPress in config.php not working
Try installing/enabling the PHP Curl extension. apt-get install php5-curl
Add Google Analytics To A WordPress Site
Paste the following code into your functions.php file replacing the UA-xxxxxxxx-x code with your Google Analytics code. function googleanalytics(){ ?> <script type=”text/javascript”> var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘UA-xxxxxxxx-x’]); _gaq.push([‘_trackPageview’]); (function() { var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true; ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’; var […]
Display specific post in WordPress
To display a specific post by post ID, add the following code to your WordPress template file. <?php //Select specific post ID $post_id=256; //To display post title echo ‘<h1>’ . get_post($post_id)->post_title . ‘</h1>’; //To display post content echo get_post($post_id)->post_content; ?> Tested with WordPress 3.3
How to list a specific number of posts from 1 category in WordPress
You can place the following code in one of your theme’s template files to list a particular amount of posts from one of your site’s catagories. <h2>Last 5 Tutorials</h2> <?php query_posts(‘category_name=tutorials&showposts=5’); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <?php endwhile; ?> Tested with WordPress 3.3
Add a Read More link to the_excerpt() in WordPress
To remove the default […] marker at the end of an excerpt and add a Read More link add the following code to your theme’s functions.php file function new_excerpt_more($more) { global $post; return '<a href="'. get_permalink($post->ID) . '"> Read More…</a>'; } add_filter('excerpt_more', 'new_excerpt_more'); Tested with WordPress version 3.3