Category Archives: Wordpress 3

WP Snippets

Add text snippet as a custom post then access it via a shortcode:

 HTML |  copy code |? 
1
[snippet slug="my-cool-snippet" /]

or in template

 PHP |  copy code |? 
1
 echo do_shortcode('[snippet slug="my-cool-snippet" /]'); 

More information from the plugins site:

http://www.websharks-inc.com/product/wp-snippets/

Posted in Plugins | Leave a comment

Track Contact Form 7 Submissions using Google Analytics

In additional settings field of Contact From 7 admin:

 HTML |  copy code |? 
1
on_sent_ok: "_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"

Google Analytics will track it as an event with Contact Form as the Category, and Submit as the Action.

In Google Analytics go to Content > Events > Overview

Posted in Contact Form 7, Plugins, Wordpress 3 | 2 Comments

Update all URLs in database except in serialize data

Updating URLs in the database can cause problems if you include those in serialized arrays.

These queries leave serialized arrays untouched:

 MySQL |  copy code |? 
1
UPDATE wp_options SET option_value = REPLACE(option_value, ‘http://devdomain.local, ‘http://livedomain.com‘) WHERE option_value NOT LIKE%{%; UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘http://devdomain.local, ‘http://livedomain.com‘) WHERE meta_value NOT LIKE%{%; 

More info here:

http://wp-types.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

Posted in Tips and Tricks, Wordpress 3 | Leave a comment

Enable ‘Read More’ link in posts outside the default blog page

Add the $more variable before the content in the loop:

 PHP |  copy code |? 
1
global $more; 
2
$more = 0; 
3
the_content('[Read more...]');

Posted in Tips and Tricks, Wordpress 3 | Leave a comment

Access to password protected directory giving 404 file not found error

If you have a directory protected by a password using HTTP Basic Authentication (set up in cpanel for instance) you will get 404 errors due to the way the WordPress permalinks works.

The solution is to add this to the top of your .htaccess file in the site root:

 HTML |  copy code |? 
1
#prevent 404s when accessing password protected directories
2
ErrorDocument 401 ./error.html
3
ErrorDocument 403 ./error.html
4

You dont need to upload a valid error.html file

Full explanation here:

http://www.myguysolutions.com/2010/02/10/how-to-fix-wordpress-404-errors-on-password-protected-directories/

Posted in Tips and Tricks | Leave a comment

Conditional output if post body is empty

There is a bug in views related to conditional output based on post content so this is a work around.

In themes functions file:

 HTML |  copy code |? 
01
// Views test for post content
02
add_shortcode ( 'wpv-post-getcontent', 'wpv_getcontent' );
03
 function wpv_getcontent() {
04
global $post;
05
 if(get_the_content() != '') :
06
 return 1;
07
else :
08
 return 0;
09
endif;
10
wp_reset_query();
11
 }

Then in view template:

 HTML |  copy code |? 
1
[wpv-if evaluate="'[wpv-post-getcontent]' = '1'"]Conditional output here[/wpv-if]

Original post here:

https://wp-types.com/forums/topic/testing-for-empty-post-body/

Posted in Views | Leave a comment

Use blog_info data in Views

For instance to show blog_info(‘url’) field in a view:

 HTML |  copy code |? 
1
[wpv-bloginfo show='url']

Posted in Views | Leave a comment

Conditional Featured Image Present

To show the featured image if it is present:

 HTML |  copy code |? 
1
[wpv-if image="_thumbnail_id" evaluate="!empty($image)"]
2
<div class="my_featured_image">[wpv-post-featured-image size="full"]</div>
3
[/wpv-if]

Posted in Views | Leave a comment

Horizontal Accordions Shortcode

 HTML |  copy code |? 
1
[haccordions title="" width="800" height="320" hwidth="28" activateon="click" active="0" speed="800" autoplay="false" pauseonhover="true" cyclespeed="6000" theme="jqueryui" rounded="false" enumerate="false"] [haccordion title="Pane 0"] Accordion pane 0 content] [/haccordion] [haccordion title="Pane 1"] Accordion pane 1 content [/haccordion] [haccordion title="Pane 2"] Accordion pane 2 content [/haccordion] [/haccordions]

Parameters:

 title

(text) The title shown above the accordion group
Default: “” (empty string)

width

(integer) Width of the haccordion in px
Default: 960

height

(integer) Height of the haccordion in px
Default: 320

hwidth

(integer) Width of each header (vertical bars) in px
Default: 28 (jqueryui theme) or 48 (all other themes)

activateon

(text) “click” or “mouseover”: Which user input triggers opening of slides
Default: “click”

active

(integer) Index of the pane that should be selected on page load with the left-most pane being 0
Default: 0

speed

(integer) Duration of animation in ms
Default: 800

autoplay

(boolean) Set to true to automatically scroll through slides
Default: false

pauseonhover

(boolean) If true the autoplay will be paused when the mouse is in the haccordion
Default: true

cyclespeed

(integer) Time between opening each slide (when autoplay is true)
Default: 6000

theme

(text) One of: jqueryui, basic, dark, light or stitch
Default: “jqueryui”

basic, dark, light and stitch are the themes that liteAccordion and Accordion Pro use.

rounded

(boolean) Set to true to round the corners of the haccordion
Default: false

enumerate

(boolean) If true the slide number will be shown in each slide
Default: false

Posted in Squelch Tabs and Accordians | Leave a comment

Display Sibling Posts using WP Views

This is based on this tutorial:

http://wp-types.com/documentation/user-guides/displaying-brother-pages/

But I couldn’t get it working until by trial and error I found that the following worked:

  1. Create a view that pulls the child post using the filter
    Select related posts that are a child of the post where this View is inserted.“eg: “Further Works by Artist”
  2. Create a View Template that uses this Vieweg: “Further Works” which uses [wpv-view name="Further Works by Artist"]
  3. Insert the View Template in the View template used to show a single childeg: View Template “Work Details” shows the details of a child artwork and within it we insert the view “Further Works” to show other works by the same artist:

    [wpv-post-body id="$artist" view_template="Further Works"]

    where $artist is the slug of the post type or the parent.

Posted in Views | Leave a comment