WordPress – Redirect All URLs to Homepage

If you need to redirect all the pages of your website to the homepage, while still having access to the admin area you need to add some code to the .htaccess file that resides in the main directory of your website.

While doing this, please make sure that you do not overwrite the default WordPress code for “pretty” permalinks.

Just add the following code above the one you will find in the .htaccess file.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...Loading...

Genesis – How to Add Previous/Next Post Navigation

WordPress.com has a nice feature that displays links on each article to the previous and next articles.

But if you are on WordPress.org, you will need to custom code this feature, which is not something hard to achieve.

In order to implement this, just add the following code to functions.php.

Then, once you add the code to functions.php, make sure that you also copy the CSS to the style.css to add some basic style.

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 3.75 out of 5)
Loading...Loading...

Gravity Forms – Populate Name Field

Suppose you want to create a form that allows the user to enter its name. This is a common requirement for many forms and for this reason Gravity Forms has an advanced Name field just for this purpose. As discussed in a previous article, the Name field is a multiple input field, similarly to the Address and checkbox fields.

We will discuss two methods for populating the Name field, but before we do that let’s write a function that will retrieve the logged-in user’s first and last name.

Retrieving user meta information

WordPress stores information about the currently logged-in user in an instance of the WP_User class. Using this object we can retrieve any meta data associated with the logged-in user, as shown below:

So, to obtain the current user’s first and last name, we can write:

Now let’s see how this function can be used to populate a Gravity Forms Name field with the user’s data.

Method 1 – using dynamic population parameters

This is the simplest approach and relies on the gform_field_value_$parameter_name filter, which is executed before displaying each field and can be used to dynamically populate fields with a default value.

To use this method, select the option “Allow field to be populated dynamically” in the “Advanced” tab of the Name field and enter the parameter names for the “First” and “Last” components of the name. We shall assume that the parameter names are “first_name” and “last_name”. Note that this applies to a Name field whose “Name Format” property is set to “Normal”; for “Simple” and “Extended” fields, the number of parameters is 1 and 4, respectively.

Then add the following code to your theme’s functions.php file:

Method 2 – setting field default value directly

This method is more complex but gives us more insight into the internals of the Gravity Forms Name field. First of all, we shall write a function that takes a string or array parameter and populates a Name field:

When the “Name Format” of the field is set to “Simple”, pass a string containing the full name. When the “Name Format” is “Normal” or “Extended”, pass an array with keys “first”, “last”, “prefix” (for “Extended” only), “suffix” (for “Extended” only). If you pass such an array for a “Simple” field, the first and last name components will be joined together to form the full name.

Now let’s see how this function can be used to populate the Name field. We shall use the gform_pre_render filter, which is executed before the form is displayed and can be used to manipulate the Form Object prior to rendering the form.

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading...Loading...

How to Exclude DiggDigg From Specific Pages

If you want to exclude the DiggDigg sharebar from pages like About, Contact or checkout pages (such as those for Premise), you can use the code below.

However, make sure that you replace 1, 2, 3, 4 with the ids of the pages you want to exclude DiggDigg from.

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading...Loading...

Genesis – How to Create a Custom 404 Page

If you have the Genesis framework and a child theme from StudioPress, the default 404 page will display everything that is on your blog.

And by everything I am referring at posts, pages, categories and archives that maybe you don’t want people to see.

This is what I also had on my website and I recently decided that it’s time for me to update this.

So, in order to do that, all you have to do is copy the 404.php file from the genesis directory and edit it the way you want it.

Or easier, just copy the code below, add it to a 404.php file and copy that file in the directory of your child theme. You can see how it looks by getting lost on this site.

Be careful, not in the genesis directory, but in the directory of your child theme.

Feel free to customize it the way you want it, as long as you know what you are doing:

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading...Loading...
Are You Making These 7 Conversion Mistakes?

Conversion Mistakes

Discover the 7 biggest conversion mistakes that people make (and how to avoid them, so you can get more subscribers and sales).

Join my private newsletter and get the course that will show you:

  • A sneaky way to figure out exactly what your audience wants
  • The easiest way to see where your visitors lose interest and click away
  • How to convert more visitors to email subscribers, and build a list that converts

Powered by Elevatr