Tracing the template file used by WordPress might be tricky at times.The code below print the full path and name of the template file used
Read moreWordPress – change previous next post links to post titles
The default WordPress setup on a post page is to link to the previous and next posts with the “previous” and “next” buttons. But what
Read moreContact form 7 get value before pipe (_raw_ value equivalent)
On one of our WordPress sites we used the excellent contact form 7 plugin. The plugin allows you to easily create forms for your site.
Read moreMoving to HTTPS with Cloudflare
Cloudflare offers many benefits: There’s the CDN which makes your site faster to reach in different locations. There’s the caching system which makes it even
Read moreMoving WordPress website to HTTPS – securing your site for visitors while improving SEO
Technical: Buy and install a SSL certificate Backup database and files Try to change all absolute references to relative, or change all hard-coded “http://www.yoursite.com…” into
Read moreWordPress update dates for all posts
I have a site I started but never officially launched. It has many posts and as time passes by they are getting old. Every once
Read moreForcing lowercase on one character inside an uppercase conversion title in wordpress
We have hundreds of posts on our company blog and our theme converts all the titles to uppercase letters. Lately we had one post the
Read moreDealing with a WordPress code injection attack to all js files ‘_0xaae8’
During the last week we were attacked twice. The symptom – our site redirects to advertisements. The tricky part is that after the first redirection
Read moreStrip images from HTML / Strings
Easy and simple:
1 |
$content = preg_replace("/<img[^>]+\>/i", " ", $content); |
This came handy when I had a wordpress theme that was showing on the homepage both the featured image and the
Read moreForm submit in wordpress loads a 404 page
I created a custom form on a contact page without using any plugins. After finishing with the design I tested my form and for some
Read moreAccessing database data with jQuery using a PHP proxy and avoiding the 404 error
I needed to pull database records into a page but couldn’t use PHP directly on that page (it was limited by the CMS used). So
Read morePulling latest posts from wordpress into any page
In order to pull a set number of words use:
1 2 3 4 5 6 7 8 9 10 |
<?php require($_SERVER['DOCUMENT_ROOT'].'/blog/wp-blog-header.php'); $args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date"); $postslist = get_posts( $args ); echo '<ul id="latest_posts">'; foreach ($postslist as $post) : setup_postdata($post); ?> <li><strong><?php the_date(); ?></strong><br /> <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> <?php the_title(); ?></a><br><?php echo apply_filters( 'the_content', wp_trim_words( strip_tags( $post->post_content ), 55 ) );?> </li> <?php endforeach; ?> </ul> |
Calling “wp-blog-header.php” is needed in order to have the wordpress functions available. If you
Read moreAvoiding save_post to run your code twice
When attaching a function in functions.php to save_post I found out it runs my code twice. Finally found a solution using:
1 2 3 4 5 6 7 8 9 |
$post_type = get_post_type( $post_id ); if ($post_type=='revision') { return; } if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )||$_POST['post_type']=='revision') { return; } |
Making an all width element inside a set width theme
I needed to create a slider which had to be wider than the text area. There was a max-width set by the theme, and I
Read moreMaking the footer stick to the bottom of the page when there is little content
http://ryanfait.com/resources/footer-stick-to-bottom-of-page/ When logged in to wordpress the top bar for the editor messes the height of the page so it looks like the is an
Read moreAlways show next/prev arrows in NextGen gallery
This helps mobile users to know how to navigate images in the gallery. Go to the fancybox css file “jquery.fancybox-1.3.4.css” in my version. It is
Read morePage, Post and Post List php code files
To edit, remove or style (except for the css options) titles and templates for pages and blog pages use the following files: pages: content-page.php single
Read moreWordPress contact form 7 plugin styles
You can style around the form and elements, but also add class:class_name and style the class with css: <p align=”left”>[submit class:buttons_mainpage ” “]</p> and then
Read moreCreating a child theme
A WordPress child theme is a theme that inherits the functionality of another theme, called the parent theme. Child themes allow you to modify, or
Read moreMoving A WordPress Website Installation
Moving A Website From A Subdirectory To The Root This is by far the simplest of the three moves I’m going to cover, because you
Read more