Connect with us

HOWTO'S

How to safely add custom code to WordPress websites

Published

on

how-to-safely-add-custom-code-to-wordpress-websites

Users are often looking for ways to tweak their websites, plugins and themes, or to add some modifications to an existing functionality. In most of these cases, you can do so by adding custom code to your WordPress website.

There is nothing wrong with adding custom code to your website. However, there are a few things that you need to look out for when adding custom code making these changes to your WordPress website.

This article highlights what to look out for, and the best practices to adding custom code to your WordPress website.

What to look for before adding Custom Code Snippets in WordPress

The easiest way to add code snippets authors suggest in their tutorials, is to add the code snippet to the theme’s functions.php file. However, there are a number of restrictions and disadvantages when you add code snippets to the theme’s functions.php file.

Each time you upgrade your theme the custom code snippets you added to your functions.php file will be overwritten, unless you manually upgrade the theme, or manually copy the code snippets from one functions.php file to the other. Having in mind that most developers release upgrades quite frequently, especially when using premium themes, adding code snippets to the theme’s functions.php file becomes very difficult to maintain.

Also, if you want to change the theme you have to migrate the code as well, which is definitely not good for the long run.

Another disadvantage is that the theme files are executed on every page and by adding the code snippets to the theme’s functions.php file, the risks of breaking your entire website are much higher.

Let’s check out the best practices on how to add custom code snippets to your WordPress site so you don’t need to worry again about missing some code snippet, forgetting to migrate it, or breaking a functionality when upgrading your theme.

Adding custom code snippets to WordPress sites

Custom code can be added using one of the following methods:

  • Using a plugin (refer to our WordPress plugins introduction to learn more about what WordPress plugins are)
  • Creating a custom plugin
  • Creating a child theme

Now, let’s discuss each of the methods in detail.

1. Using the Code Snippets Plugin

The Code Snippets plugin is a great way to add custom code to WordPress site, and if you are not a fan of writing some code yourself, this way is easier than creating your own plugin.

After installing the plugin a new Snippets section is added to your WordPress menu, which lets you add new snippets. Each snippet will have space for the code and a description for additional information on what the code does.

Tip: If you are using a useful code snippet from a site, add the URL in the description so you remember where the code came from.

Just like plugins you can enable and disable your custom code snippets as well as export them into PHP files. In some cases custom snippets cause conflicts with other plugins or themes, so deactivating all custom code is useful for targeting issues.

2. Creating your own site-specific plugin

Creating your own custom site-specific plugin is the best way to add custom code to WordPress sites, because you have total control of the code. No plugin or theme update will affect your custom code. Furthermore, it gives the flexibility of activating or deactivating the custom plugin as per your needs.

You do not need to be a PHP guru to create a site-specific plugin. Just follow the below three easy steps.

1. Create the plugin directory

First, you will need to create a directory for the plugin and name it. It can be any name, such as the site’s website. The plugin’s directory should be created in the /wp-content/plugins/ directory on your website. For this example, we are calling the plugin wpwhitesecurity-shortcodes. Note: always use dashes and not spaces in directory names.

2. Create the plugin file

Next, you will need a main file for your plugin. Although there are no rules in regards to what the file name should be, the best practice is for the filename to be the same as the plugin name. So in our example the plugin’s filename is wpwhitesecurity-shortcodes.php.

This file should at least include a title and a description.

Create this file using a text editor, such as NotePad ++ or TextEdit. Don’t use Microsoft Word or similar editors, because it adds formatting data to text and it might mess up your file. All the editors listed above are free.

Here’s all you need to add to the file:


That’s all about it. Now it is time to add the custom code.

3. Add the custom code snippets

Now you can copy and paste the code snippets from tutorials etc. into this file. If you have created the plugin file offline, compress the plugin’s folder as a .zip file and upload to your website from the WordPress dashboard.

From now on you don’t need to worry about missing some code snippet, forgetting to migrate it, or breaking some functionality when upgrading your theme or your WordPress. Next time you encounter a WordPress code snippet and would like to add it to your website, add it to the site-specific plugin file.

4. Add an index.php file (optional)

This is an optional step. To avoid directory listing you should add an index file in the plugin directory. All you need to do is:

Create a file called index.php

Add the following content to it:


3. Use child theme functions.php

Earlier we said not to use your theme’s functions.php file. However, this is a good alternative for certain changes, for example, for theme specific changes. In this way, the theme specific custom code is out when your theme is, as it won’t be needed anymore.

Nevertheless, theme changes should always be added to the child theme, and not the parent one, so it’s upgrade-safe.

If you add code to your functions.php, always make sure to look for closing PHP tags. This is how they look like: ?>. If your theme file ends in one of these, you should put the custom code above that.

Directory of child themes functions.php

Conclusion

As we have just seen, there are a few different ways to add custom code to your WordPress website, but not all of them are good in the long run. However, some of them are better than others at specific things. For example, for theme specific changes (looks & feel of the website), add custom code to the functions.php file. For any other changes, ideally you should have your custom site-specific plugin

Just make sure that you add custom code to WordPress in a way that’s safe, and makes it easy to debug if something goes wrong.

We hope this article helped you learn how to easily add custom code snippets in your WordPress sites.

The post How to safely add custom code to WordPress websites appeared first on WP White Security.

Author: Radostin Angelov
This is a Security Bloggers Network syndicated blog from WP White Security Read the original post at: https://www.wpwhitesecurity.com/safely-add-custom-code-wordpress-websites/

Read More

HOWTO'S

This unused Star Wars poster could have ruined everything

Published

on

This unused Star Wars poster could have ruined everything

A recent unused poster design for 1977’s Star Wars has surfaced and reveals just when you think you’ve seen it all around this iconic movie, there’s always something new to talk about. Particularly as this rare and unused Star War movie poster art was so bad it could have ruined the franchise before it even launched.

The unused Star Wars poster from 1977 was posted on Twitter by film nerd’ account The Spaceshipper and many fans of the franchise were thankful it was never used. While some recent film posters, like new Ant-Man 3 posters that are a Photoshop nightmare, this rare Star Wars poster is bad on so many levels – it’s a graphic design fail, the slogan makes no sense and there’s little to engage with.

Star Wars film posters have been some of the best ever designed, from legendary artists such as the Hidlebrandt Brothers who painted the original 1977 poster that was used. Iconic poster artists have also designed for the franchise; the Drew Struzan Star Wars poster for The Force Awakens impresses and Hugh Flemming revealed all in our feature ‘the secrets of a top Star Wars artist’.

Continue Reading

HOWTO'S

How to Manage Your Online Brand?

Published

on

You might be asking yourself, “Why do I need to manage my online brand?” It’s a valid question, especially if you’re not sure what managing your online brand means precisely.

In short, managing your online brand is the process of taking control of how others see you and your business online. This can involve creating and maintaining a strong presence on social media, developing positive reviews and testimonials, and monitoring your web analytics to track progress.

By taking the time to manage your online brand, you can improve your chances of success in today’s digital age.

In this article, we’ll explore some key reasons why managing your online brand is essential.

What is an online brand, and why do you need one?

Your online brand is the way you are perceived by others online. This includes your website, social media profiles, online reviews, and all other digital real estate that represents you when someone searches for you or your business.

It’s important to have one because it helps your potential customers get to know, trust, and like you before they buy anything from you. A strong online brand can also help you attract new customers and grow your business.

It’s good to remember that your online brand is the first thing people will see when they search for you, so it’s important to make sure it represents you and your business well.

How to manage your online brand for success?

Your online brand is your reputation. It’s how people perceive you when they see your name, read your work, or interact with you online.

A strong online brand can help you attract new clients, collaborators, and opportunities. But how do you create and manage your brand for success?

1) Consider what you want your online brand to convey.

Are you an expert in a certain field? A thought leader? A creative visionary?

Once you know what you want your brand to communicate, be consistent in everything you do online.

Use the same name, photo, and bio across all of your social media platforms. Post regularly about topics related to your brand, and make sure the tone of your posts is consistent with the image you’re trying to convey.

2) Interact with other people online in a way that reinforces your brand.

When someone mentions you in a post, thank them publicly. If someone leaves a negative comment on one of your posts, don’t delete it – instead, respond politely and professionally.

By managing your online brand thoughtfully and proactively, you can set yourself up for success both online and offline.

3) Monitor your web analytics to track your progress.

Use Google Analytics or another web analytics tool to track how people are finding you online and what they’re doing on your website. This data can give you insights into what’s working well and what needs improvement.

For example, if you see that most of your website visitors are coming from Facebook, you might want to focus on creating more engaging content for that platform.

Or, if you notice that people are spending a lot of time on your blog but not your sales page, you might need to work on driving traffic to your products or services.

4) Make sure your website represents your brand well.

Your website is often the first thing people will see when they search for you online, so it’s important to make sure it’s up-to-date and represents your brand well.

Update your website regularly with new blog posts, photos, and products. Use attractive visuals, easy-to-navigate menus, and clear calls to action.

If you’re not sure how to create a website that represents your brand well, consider working with a web designer or developer.

5) Pay attention to your social media presence.

Social media is a powerful tool for managing your online brand. Use it to connect with your audience, share your work, and promote your products or services.

Be sure to post regularly, interact with others, and use hashtags and keywords that will help people find you. You can also use social media ads to reach a wider audience or promote specific products or services.

6) Monitor your online reputation.

Use Google Alerts or another tool to monitor your online reputation. This will help you stay on top of what people are saying about you online and take action if necessary.

For example, if you see a negative review of your business, you can reach out to the customer directly to try to resolve the issue. Or, if you see someone spreading misinformation about your work, you can correct it.

7) Manage your online brand proactively.

The best way to manage your online brand is to be proactive. Be thoughtful about everything you do online, from the content you post to the way you interact with others. By taking control of your online presence, you can set yourself up for success both professionally and personally.

By following these tips, you can create and manage an online brand that will help you achieve your goals.

The benefits of having a strong online brand

Let’s look at a few benefits of having a strong online brand:

1) Stand out from the competition.

With so much noise online, it can be difficult to stand out from the crowd. But if you create a well-defined brand, you’ll be better able to cut through the clutter and attract attention.

2) Build trust and credibility.

A strong online brand can help you build trust and credibility with your audience. If people know what to expect from you, they’re more likely to trust and respect you.

3) Connect with your audience.

By definition, a brand is a way of differentiating yourself from others. But it’s also a way of connecting with your audience on a deeper level. When done well, branding can create an emotional connection between you and your audience.

4) Drive traffic and sales.

A strong online brand can help you drive traffic and sales. If people are familiar with your brand, they’re more likely to buy from you. And if they trust and respect you, they’re more likely to tell others about you.

5) Increase your visibility.

A well-managed online brand will increase your visibility online. When people search for you or your business, you’ll be more likely to show up in the search results. And when people see you frequently in their feeds, you’ll be more likely to stay top of mind.

6) Attract media attention.

A strong online brand can help you attract media attention. If you’re known for something specific, journalists and bloggers will be more likely to write about you. This can help increase your visibility and reach even further.

7) Enhance your career prospects.

Your online brand can have a big impact on your career prospects. If you’re looking for a new job, employers will likely research you online. And if you’re an entrepreneur, investors will want to know more about your brand before they invest in your business.

8) Make a positive impact.

Finally, a strong online brand can help you make a positive impact in the world. If you’re passionate about something, you can use your platform to raise awareness and advocate for change.

The importance of staying consistent with your branding strategy

As you can see, there are many benefits to having a strong online brand. But it’s not enough to just create a brand—you also need to be consistent with your branding strategy.

When it comes to branding, consistency is essential. Your audience needs to know what to expect from you, and they need to see that you’re consistent in your messaging and your visuals.

Here are a few pointers if you’re not sure how to stay consistent with your branding:

1) Define your brand.

The first step to being consistent with your branding is to define your brand. What do you want people to think of when they see your name or your logo? What do you want your brand to represent?

2) Create guidelines.

Once you’ve defined your brand, it’s time to create guidelines. These guidelines should include everything from your mission statement to the colors and fonts you use in your branding. By having a set of guidelines, you’ll be able to ensure that all of your marketing materials are on-brand.

3) Train your team.

If you have a virtual assistant or team, it’s important to train them on your branding guidelines. Make sure everyone knows what your brand represents and how they can help you maintain a consistent brand identity.

4) Monitor your brand.

Once you’ve launched your brand, it’s important to monitor it. This means paying attention to how people are reacting to your brand and making sure that you’re still presenting yourself in the way you want to be seen.

5) Be prepared to adjust.

Finally, be prepared to adjust your branding strategy as needed. As your business grows and changes, your branding will need to change with it. By being flexible and willing to adjust, you’ll be able to ensure that your brand is always relevant.

Wrap Up

A strong online brand is essential for any business or individual. By definition, your online brand is the way you’re perceived by others online. And while that may seem like a superficial thing, the reality is that your online brand can have a big impact on your business or career.

If you’re not sure how to create a strong online brand, start by defining your brand and creating guidelines. Then, train your team on your branding strategy and monitor your brand over time. And finally, be prepared to adjust as needed.

About:
Oscar is a passionate full-time blogger and a part-time author. In his personal blog OssieRodriguez.com, he writes about software, online influence, and different business models.

Continue Reading

HOWTO'S

How SEO Works in Digital Marketing

Published

on

how-seo-works-in-digital-marketing

Search engine optimization (SEO) is an integral part of digital marketing.

SEO helps with brand discoverability. When done right, SEO can create the most consistent and by far the highest-quality traffic source which doesn’t require on-going maintenance.

Yet, SEO is usually the most isolated part of the marketing. Whether it is an in-house team or a third-party service that’s delivering your SEO campaigns, it usually exists on its own without really communicating goals, progress or results to the whole company.

This creates silos that can lead to poor results and even reputation crises.

How does SEO work in digital marketing and how can a business make it work better?

What is SEO?

SEO is a collection of tactics (content, technical, link building, even website security and usability) that ensures that your website is easy to understand for search engines.

Basically, it ensures a machine knows that your page will be easy to find to a human being who is looking to solve a related problem.

Search engine traffic is one of the highest-quality traffic for many reasons:

  • Unlike PPC (paid) traffic, it doesn’t require an ongoing investment to keep coming
  • Unlike social media traffic,  it doesn’t require an ongoing work to keep coming
  • Unlike social media traffic, you are not interrupting people’s browsing. Instead you give them what they were actually searching for.

In other words, it is consistent and it converts well. No other digital marketing tactic beats that.

Apart from driving direct traffic, search engine optimization helps build brand awareness by increasing your brand’s organic findability.

Keep Your Whole Team Aware of Why SEO is Important

The great thing about today is that everyone understands the value of ranking high on Google! Sadly, however, many folks only know that they “need SEO” without having really understood what that means. 

SEO these days is too hard for a digital marketer to do alone. Many SEOs find themselves in situations where an executive will simply come down and go “Why are we not ranking well for ‘dingwobble’?” 

Keep working hard with teams for them to understand how they contribute to the SEO process:

  • Product Marketers who are responsible for the business, personas and messaging understand that SEO is critical to driving the bottom line revenue numbers they are looking at. Part of the persona developing process should be the development of the “digital persona” – what websites and search terms are these people looking for? This helps the product marketer when it comes time to develop messaging, as that is going to be critical for developing the content, so the right search terms better be there!
  • Field Marketers responsible for the campaigns need to know how SEO fits within their campaign, how it in fact is core to our demand generation, and how to make sure to keep the campaigns integrated.
  • Marketing Communications is creating the content, so SEO should very well be top of mind for them, as the content itself will be critical in impacting how successful SEO will be.
  • But that’s not all! Often, other groups are creating content (Press Releases, Blog Posts, Presentations, etc.) that also end up on the web and impact SEO. Whether it’s Corporate Communications, Investor Relations or even Legal teams, working with them is critical.
  • IT manages the infrastructure and can be very critical to the technical aspects of SEO.
  • Sales and customer support teams are at the forefront of marketing talking to your future and current customers, so they need to be involved in the SEO strategy. Creating relevant content goes beyond keywords. It needs to address real problems and answer actual people’s questions, and your client-facing teams will be your best source of inspiration here.  
  • Executives also care! While they can’t often influence the day-to-day of SEO, they will care a lot about the bottom line, to which SEO contributes.

Educating all of these people about SEO helps empower them, as well as position yourself, the SEO, as the subject matter expert who is not just someone back-office who gives very little visibility into the black box of SEO, but someone who is actively educating and contributing to the organization’s success.

Review and discuss common KPIs early and often to make sure everyone knows what victory looks like to the team.

Additionally, SEO should be a solid part of any project launch as it impacts every stage of product positioning. From choosing a business name to choosing a website builder, your initial efforts should be driven by SEO best practices.

What is the key to SEO success in a constantly changing environment?

As a practitioner of SEO, I believe that you need to look to ensure you are looking at both developing yourself in both depth and breadth of knowledge. A key danger in the name of being informed or being a part of the SEO community is spending all your time debating tactics and practices rather than testing them. 

Additionally, SEOs as with all employees need to look outside their field to stretch and learn how to be more well rounded. This could mean learning to code, or educating yourself in some other area of the business you work for.  This will expose you to ideas others may not have.

As a manager of people, success is really about diversity of expertise. Who you hire and the kind of people you hire will be far more valuable than much of what people invest in with regards to SEO programs. You have to have people who can roll with the punches and develop a skill for self-management and personal growth. 

Finally, I think knowing what your real goals are in having an SEO program are the key to long term success. The reality is you may get more traffic, but if that traffic is not from qualified leads and generates real revenue then the benefit may be very little. Having well defined goals and metrics will also help you avoid chasing algorithm changes and focus on the big picture.

Conclusion

SEO is the most essential long-term digital marketing strategy but to make it really effective, you need a knowledge team that is well-integrated into the company’s life. Good luck!

Ann Smarty

Ann Smarty is the brand NINJA at Internet Marketing Ninjas as well as the founder of numerous startups including MyBlogGuest, MyBlogU, ViralContentBee, TwChat and many more.

Ann Smarty has been an online marketing consultant for 10 years providing high-quality digital marketing consulting through her services and courses (both free and paid).

Ann Smarty’s content marketing ideas have been featured in NYtimes, Mashable, Entrepreneur, Search Engine Land and many more. She is known for her indepth tool reviews, innovative content marketing advice and actionable digital marketing ideas.

Source: Ann Smarty

Continue Reading

Trending

en_USEnglish