29 Best WordPress Themes for Artists (2017)

Are you looking for the best WordPress themes for artists? Sometimes its hard to find the perfect theme that can showcase your creativity and talent. In this article, we have hand-picked some of the best WordPress themes for artists. Building a WordPress Site for Artists… Read More »

The post 29 Best WordPress Themes for Artists (2017) appeared first on WPBeginner.

Are you looking for the best WordPress themes for artists? Sometimes its hard to find the perfect theme that can showcase your creativity and talent. In this article, we have hand-picked some of the best WordPress themes for artists.

Best WordPress themes for artists

Building a WordPress Site for Artists

Due to the flexibility and freedom it offers, WordPress is used by artists all over the world to share and promote their work online.

First you need to make sure that you are using the right platform. A self-hosted WordPress site gives you the freedom to use all features of WordPress.

Next, you need to sign up for a WordPress hosting account and register a domain name.

We recommend using Bluehost for hosting because they are one of the largest hosting companies in the world and an official WordPress recommended hosting partner. They are also offering our users 65% off + a free domain name.

Once you have signed up for hosting, it is time to install WordPress. Head over to our step by step guide on how to start a WordPress blog and you will be up and running in no time.

You can now choose a theme for your WordPress site. Select a theme from our list below. If you need help installing the theme, then check out our guide on how to install a WordPress theme.

Having said that, let’s take a look at some of the best WordPress themes for artists.

Note: This list contains both free and paid WordPress themes and all of them are fully mobile responsive.

1. Creatica

Creatica

Creatica is a multi-purpose WordPress theme for artists, creative agencies, art blogs, and more. It ships with stunningly beautiful and ready-made demos that you can install with 1-click.

It also includes tons of customization options like multiple header styles, multiple sidebars, custom widgets, and a powerful theme options panel. You will also get a slider plugin and a powerful drag and drop page builder to create your own page layouts.

2. Meteor

Meteor

Meteor is an elegantly designed WordPress theme for artists, arts and crafts, and portfolio websites. It includes grid, carousel, masonry, and blocks portfolio templates, allowing you to beautifully display photos, projects, paintings, illustrations, videos, and more.

It also allows you to choose different layouts for each single project in your portfolio. You can also choose 4 layout styles for your posts. It also includes a template to create a resume page and a section to add services.

3. Martho

Martho

Martho is a WordPress multipurpose theme that can be used by bloggers, photographers, and artists. It is highly flexible and perfect if you want to grow your website and be able to add different things as it grows.

Martho includes multiple homepage designs, templates for blog, project pages, galleries, and more. It is WooCommerce ready and has portfolio post type built-in with multiple display options. It also ships with a drag and drop page builder.

4. Indigo

Indigo

Indigo is a gorgeous multipurpose WordPress theme carefully designed with an artistic approach to details. It comes with easy to use modules that you can just drag and drop to build your homepage layout.

It also includes 14 ready made templates to make a website. You can install and then just replace the content with your own. These websites include a blog, magazine, portfolio, and stories theme that would work perfectly for an art website.

5. Freelo

Freelo

Freelo is a beautifully designed WordPress theme for artists, illustrators, and art blogs. It has a built-in portfolio section with multiple styles using beautiful CSS animations. You can choose from multiple color schemes and create your own as well.

It allows you to easily change fonts and has support to use Google Fonts. There are multiple page templates, unlimited sidebars, and even a sidebar generator packed inside.

6. Nico

Nico

Nico is a beautifully designed WordPress theme for artists, photographers, illustrators, and more. It includes a gorgeous filterable portfolio with grid layout that helps you display your work elegantly.

Nico includes several customization options such as custom colors, custom background and header, and social media integration. It has a custom theme panel to help you easily build your website.

7. Heron

Heron

Heron is a minimalist WordPress theme for artists, bloggers, and writers. It features beautiful typography, earth toned colors, and a clean spacious layout. It uses large fully scalable featured images and videos, which makes your pages more engaging.

It has a full screen search overlay next to the navigation menu on top. It also comes with author bio box for multi-author WordPress sites. It is easy to setup and customize using the built-in theme options panel.

8. Designer

Designer

As the name suggests, Designer is a creative WordPress theme for graphic designers, illustrators, and artists. It includes a portfolio content type with multiple styles to display portfolio items. Theme homepage has a two column layout on desktop, and a single column layout on mobile.

It uses the minimalist approach to design, which offers a distraction-free and engaging view to showcase your portfolio items. Designer uses crisp elegant typography so the text looks great on mobile and desktop devices. It has a getting started page to walk you through theme set up process.

9. Ambiance Pro

Ambiance

Ambiance Pro is a WordPress theme for artists, bloggers, and photographers. It is built on the rock solid foundation of Genesis framework. Designed specifically to beautifully showcase your photos and images, Ambiance Pro comes with beautiful layout choices and elegant typography.

It has multiple page templates for your blog, archives, and landing pages. It is quick and easy to setup using the live theme customizer. The homepage is fully widgetized so you can easily set it up in minutes.

10. Creativo

Creativo

Creativo is a flexible WordPress theme suitable to build almost any kind of website. It includes a built-in portfolio section with beautiful display options. It also has several layout choices for your blog and homepage, and it can also be used as a single page theme.

Inside you will also find sections to add services, photo galleries, testimonials, and more. Creativo ships with bonus premium page builder, slider, and a live chat plugin.

11. Exposure

Exposure

Exposure is a stylish multi-purpose WordPress theme with portfolio management system built-in. It is ideal for photography, fashion, lifestyle, arts and crafts websites.

It comes with a drag and drop page builder which allows you to design your pages the way you want. It has lots of customization options built-in and it is fully mobile responsive.

12. Coastline

Coastline

Coastline is a beautiful WordPress portfolio theme with unique design. It includes powerful custom widgets, multiple layout choices, and a well crafted portfolio section.

It has a fixed left sidebar with custom background support and comes with different page templates for blog, portfolio, archives, and galleries.

13. Relive

Relive

Want to tell your stories with an engaging layout? Check out Relive. It is a WordPress theme for storytellers, photographers, artists, and more. It is designed to offer an immersive user experience with audio, video, images, and text.

It is ideal for long form content, portfolios, photo and video galleries. It has beautiful templates for single posts and pages, photo galleries, and a unique homepage layout. Inside you will also find tons of customization options with color schemes, sidebars, custom widgets, shortcodes, and more.

14. Candid

Candid

If storytelling is a big part of your project, then you will love Candid. It is a beautiful WordPress theme for publishers with a focus on great typography and gorgeous display of images. It takes the minimalist approach to design with generous white space and modern layouts.

It features a dynamic, masonry-style layout that can be configured into one, two or three columns to match your content. It also ships with portfolio content type allowing you to showcase your photos, images, audio, or video projects.

15. Suarez

Suarez

Suarez is a stunningly beautiful and modern WordPress theme for bloggers, photographers, artists, and storytellers. It is designed to offer an immersive user experience with dazzling display of photographs and images.

The homepage layout features a large full screen header image at the top, which is followed by a masonry grid of your most important content with clever usage of images. Other features include categories carousel, sidebar filters, subcription box, social media widgets, and more.

16. Nisarg

Nisarg

Nisarg is a beautiful free WordPress theme suitable for artists and bloggers. It comes with a clean layout with two navigation menus and a large full-width header image.

It also supports custom backgrounds, custom colors, and multiple post formats for video, galleries, and other posts. All theme options are easily customizable using the theme customizer.

17. Peak

Peak

Peak is a modern WordPress theme with unique layout and style. Suitable for artists, illustrators, and photographers. It features a tile based display of images in a responsive grid layout.

It comes with multiple layouts for pages as well as posts. Other features include a mega menu on top, social media menu, slide-in sidebar widgets, easy setup, and more.

18. Memories

Memories

Memories is a beautiful WordPress theme designed for lifestyle, fashion, arts, and personal websites. It comes with a gallery display that showcases your photographs, designs, and other visual artworks beautifully.

The theme includes multiple color schemes, multiple layout choices, custom background, and header support as well as custom widgets for your social media profiles.

19. Sanremo

Sanremo

Sanremo is a free WordPress theme for bloggers and artists. It features a minimalist spacious layout with large featured images. It also includes custom widget for social media links, a sticky navigation menu at top, and a footer widget area.

20. Mozzy

Mozzy

Need a bright and lively WordPress theme for your illustrations? Check out Mozzy. It is a WordPress portfolio theme for illustrators, graphic designers, and photographers. It includes a widgetized homepage layout with a slider and featured content areas.

It comes with built-in sections for portfolio, services, and clients. Other features include custom post formats, backgrounds, headers, and social widgets.

21. Draft

Draft

Draft is another free WordPress theme suitable for artists, illustrators, and bloggers. It uses featured images to display a grid based layout on the homepage. It comes with a welcome message box, custom colors, header and background support. All theme options can be setup using customizer.

22. North

North

Looking for a great combination of elegant typography and unique layout? North is the perfect mix of the both. It is a WordPress portfolio theme with a minimalist design approach and a grid layout.

It has beautiful portfolio templates to display portfolio items like images, photos, videos, and audio files. It includes multiple color choices, post format support, and can also be used with third party photo gallery plugins.

23. Parallax

Parallax

Parallax is a modern and stylish WordPress theme for portfolio, arts, and photography websites. It features fullscreen parallax backgrounds and a unique layout. It ships with 40 different layouts that can be installed with 1-click. It also has an integrated drag and drop page builder.

Among other features you will find custom widgets for social media, portfolio section, and image filters. It can be used as a single page theme, a single page with infinite scroll, or as a regular multi-page theme.

24. Hestia

Hestia

Hestia is a free WordPress theme with powerful features to build any kind of website. It comes with a companion plugin which adds testimonials, services, and homepage sections to your website.

It is ready to be used with popular free page builder plugins, and it also supports WooCommerce out of the box. Hestia is easy to setup using the live theme customizer.

25. Verb

Verb

Verb is gorgeous WordPress theme built specifically for designers, photographers, and artists. It puts the best of your work at the top using an elegant masonry grid layout. It includes full-width templates to display individual portfolio items and pages. It also includes a traditional blog template with a right sidebar.

Verb offers pain free setup with options you need and none that you don’t need. It also includes with a getting started page to help you get started in minutes.

26. Profile

Profile

Looking for a theme to promote your personal brand? Profile is a WordPress theme to promote your personal brand online. It ships with social media integration to all your social media profiles. It also includes a beautiful portfolio section.

The homepage displays your personal photo at the top, which is followed by your Twitter feed, social profile links, blog posts, and portfolio items. It is easy to customize and comes with several shortcodes, templates, and custom widgets.

27. It is a Wrap

Wrap

If video plays an important role in your artwork, then Wrap can be the perfect way to display it. It has three homepage layouts, several content discovery features, and a beautiful media playback popup for your videos.

It also includes 4 creative header styles, featured content carousel, social media integration, and a visual page builder. It includes several page layouts, custom widgets, and easy customization options.

28. Eclipse

Eclipse

Eclipse is a stylish WordPress theme for photographers, artists, and bloggers. Theme homepage features a beautiful slider showcasing your latest work. It also displays your pages and recent posts in blocks on the homepage.

It comes with a custom widget to display your Instagram photos and videos. It also has beautiful gallery templates, portfolio section, and is fully compatible with WooCommerce.

29. Everly

Everly

Everly is a sophisticated WordPress theme for personal websites, blogs, and artists. It takes the minimalist approach to design with a spacious layout that makes your images popout. It comes with 4 different homeopage and blog layouts, post templates, galleries, and icon fonts.

It comes with unlimited colors, slider plugin, social media integration, dedicated ad spaces, and much more. Theme setup is quite simple allowing you to quickly get started without struggling with settings.

That’s all for now. We hope this article helped you find the best WordPress themes for artists and designers. You may want to take a look at our Envira Gallery plugin if you want a more robust WordPress gallery solution to display your work.

Also don’t forget to check out our ultimate step by step WordPress SEO guide for beginners to boost your SEO rankings.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post 29 Best WordPress Themes for Artists (2017) appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Solved: Surface Pro 3 USB Driver Issues with the Surface Diagnostic Toolkit

I’ve got a personal Surface Pro 3 that I like very much. It’s worked great for years and I haven’t had any issues with it. However, yesterday while installing a 3rd party USB device something got goofed around with the drivers and I ended up in this state.

Universal Serial Bus (USB) Controller banged out in Device Manager

That “banged out” device in my Device Manager is the root Universal Serial Bus (USB) Controller for the Surface. That means everything  USB didn’t work since everything USB hangs off that root device node. I know it’s an Intel USB 3.0 xHCI Host Controller but I didn’t want to go installing random Intel Drivers. I just wanted the Surface back the way it was, working, with the standard drivers.

I tried the usual stuff like Uninstalling the Device and rebooting, hoping Windows would heal it but it didn’t work. Because the main USB device was dead that meant my Surface Type Keyboard didn’t work, my mouse didn’t work, nothing. I had to do everything with the touchscreen.

After a little poking around on Microsoft Support websites, a friend turned me onto the “Surface Tools for IT.” These are the tools that IT Departments use when they are rolling out a bunch of Surfaces to an organization and they are regularly updated. In fact, these were updated just yesterday!

Surface Diagnostic Toolkit

There are a number of utilities you can check out but the most useful is the Surface Diagnostic Toolkit. It checks hardware and software versions and found a number of little drivers things wrong…and fixed them. It reset my USB Controller and put in the right driver and I’m back in business.

This util was useful enough to me that I wish it had been installed by default on the Surface and plugged into the built-in Windows Troubleshooting feature.


Sponsor: Seq is simple centralized logging, on your infrastructure, with great support for ASP.NET Core and Serilog. Version 4 adds integrated dashboards and alerts – check it out!


© 2017 Scott Hanselman. All rights reserved.
     

I've got a personal Surface Pro 3 that I like very much. It's worked great for years and I haven't had any issues with it. However, yesterday while installing a 3rd party USB device something got goofed around with the drivers and I ended up in this state.

Universal Serial Bus (USB) Controller banged out in Device Manager

That "banged out" device in my Device Manager is the root Universal Serial Bus (USB) Controller for the Surface. That means everything  USB didn't work since everything USB hangs off that root device node. I know it's an Intel USB 3.0 xHCI Host Controller but I didn't want to go installing random Intel Drivers. I just wanted the Surface back the way it was, working, with the standard drivers.

I tried the usual stuff like Uninstalling the Device and rebooting, hoping Windows would heal it but it didn't work. Because the main USB device was dead that meant my Surface Type Keyboard didn't work, my mouse didn't work, nothing. I had to do everything with the touchscreen.

After a little poking around on Microsoft Support websites, a friend turned me onto the "Surface Tools for IT." These are the tools that IT Departments use when they are rolling out a bunch of Surfaces to an organization and they are regularly updated. In fact, these were updated just yesterday!

Surface Diagnostic Toolkit

There are a number of utilities you can check out but the most useful is the Surface Diagnostic Toolkit. It checks hardware and software versions and found a number of little drivers things wrong...and fixed them. It reset my USB Controller and put in the right driver and I'm back in business.

This util was useful enough to me that I wish it had been installed by default on the Surface and plugged into the built-in Windows Troubleshooting feature.


Sponsor: Seq is simple centralized logging, on your infrastructure, with great support for ASP.NET Core and Serilog. Version 4 adds integrated dashboards and alerts - check it out!



© 2017 Scott Hanselman. All rights reserved.
     

WordPress Custom Fields 101: Tips, Tricks, and Hacks

Ever wondered what are custom fields in WordPress? Want to learn more about how custom fields work? In this article, we will show you how to user WordPress custom fields with tips, tricks, and hacks. Since this is a lengthy article, we have added table… Read More »

The post WordPress Custom Fields 101: Tips, Tricks, and Hacks appeared first on WPBeginner.

Ever wondered what are custom fields in WordPress? Want to learn more about how custom fields work? In this article, we will show you how to user WordPress custom fields with tips, tricks, and hacks.

Custom Fields 101

Since this is a lengthy article, we have added table of contents for easier navigation.

What are WordPress Custom Fields?

WordPress custom fields are metadata that are used to add additional information related to the post or page such as title, author name, date / time, etc.

By default, when you write a new post, page, or any content type, WordPress saves it into two different areas. The first part is the body of your content that you add using the post editor.

The second part is the information about that particular content. For example, title, author, date, time, and more. This information bit of the post is called metadata.

WordPress automatically adds all the required metadata to each post or page you create. WordPress also allows users to save their own custom metadata using custom fields.

By default, custom fields option is hidden on the post edit screen. To view it, you need to click on the ‘Screen Options’ button at the top and then check the custom fields option.

Show custom fields meta box

Scroll down a little, and you will be able to see the custom field meta box below the post editor.

Custom fields meta box on post edit screen in WordPress

Custom fields can be used to add any information related to the post, page, or any content type. This meta information can be displayed in your theme. However, to do that you will need to edit your WordPress theme files.

This is why this tutorial is recommended for users familiar with editing theme files. It is also helpful for aspiring WordPress developers who want to learn how to properly use custom fields in their own themes or plugins.

Having said that, let’s take a look at how to add and use custom fields in WordPress.

Adding Custom Fields in WordPress

First you need to edit the post or page where you want to add the custom field and go to the custom fields meta box.

Adding custom field

Next, you need to provide a name for your custom field and then enter its value. Click on the Add Custom Field button to save it.

The field will be stored and displayed in the custom fields meta box like this:

Saved custom field

You can edit this custom field any time you want and then click on the update button to save your changes. You can also delete it as needed.

Now you can save your post to store your custom field settings.

Displaying Custom Fields in WordPress Themes

To display your custom field on your website, you will need to edit your WordPress theme files. If you haven’t done this before, then take a look at our guide on how to copy and paste code in WordPress.

First you will need to find the theme file you need to edit to display your custom field. Ideally you would want to display it on a single post page. You will need to edit the single.php or content-single.php file.

You will need to enter your custom fields code inside the WordPress loop. Look for the line that looks like this:

<?php while ( have_posts() ) : the_post(); ?>

You want to make sure that you add your code before the following line:

<?php endwhile; // end of the loop. ?>

Now you need to add this code to your theme file:

<?php echo get_post_meta($post->ID, 'key', true); ?>

Don’t forget to replace key with the name of your custom field. For example, we used this code in our demo theme:

<p>Today's Mood: <?php echo get_post_meta($post->ID, 'Mood', true); ?></p>

You can now save your changes and visit the post where you added the custom field to see it in action.

Custom field data displayed in a WordPress theme

Now you can use this custom field in all your other WordPress posts as well. Simply create a new post or edit an existing one. Go to the custom fields meta box and select your custom field from the drop down menu and enter its value.

Select and reuse custom field

Click on ‘Add Custom Field’ button to save your changes and then publish or update your post.

Creating a User Interface for Custom Fields

As you can see, that once you add a custom field, you will have to select the field and enter its value each time you write a post.

If you have many custom fields or multiple users writing on your website, then this is not a very ideal solution.

Wouldn’t it be nice if you could create a user interface where users can fill in a form to add values into your custom fields?

This is what so many popular plugins already do. For example, the SEO title and meta description box inside Yoast SEO plugin is a custom meta box:

Custom meta box used in Yoast SEO

The easiest way to do this is by using the Advanced Custom Fields plugin. It allows you to create custom fields, group them, and display them in a custom meta box on your post edit screens in WordPress.

For detailed step by step instructions, see our guide on how to add custom meta boxes in WordPress posts and post types.

Hide Empty Custom Fields with Conditional Statement

In the above example, we showed you how to create a custom field and display it in your theme.

Now let’s see how to check if the custom field is not empty before displaying it. To do that, we will modify our code to first check if the field has data in it.

<?php 

$mood = get_post_meta($post->ID, 'Mood', true);

if ($mood) { ?>

<p>Today's Mood: <? echo $mood; ?></p>

<?php 

} else { 
// do nothing; 
}

?>

Don’t forget to replace Mood with your own custom field name.

Adding Multiple Values to a Custom Field

Custom fields can be reused in the same post again to add multiple values. You just need to select it again and add another value.

Adding multiple values to a custom field

However, the code we have used in above examples will only be able to show a single value.

To display all values of a custom field, we need to modify the code and make it return the data in an array. You will need to add the following code in your theme file:

<?php 
$mood = get_post_meta($post->ID, 'Mood', false);
if( count( $mood ) != 0 ) { ?>
<p>Today's Mood:</p>
<ul>
<?php foreach($mood as $mood) {
            echo '<li>'.$mood.'</li>';
            }
            ?>
</ul>
<?php 
} else { 
// do nothing; 
}
?>

Don’t forget to replace Mood with your own custom field name.

In this example, you would notice that we have changed the last parameter of get_post_meta function to false. This parameter defines whether the function should return a single value or not. Setting it to false allows it to return the data as an array, which we then displayed in a foreach loop.

Displaying Posts with a Specific Custom Key

WordPress allows you to display posts with custom keys and their values. For example, if you are trying to create a custom archive page to display all posts with specific custom keys, then you can use WP_Query class to query posts matching those fields.

You can use the following code as an starting point.

$args = array(
	'meta_key'   => 'Mood',
	'meta_value' => 'Happy'
);
$the_query = new WP_Query( $args );

<?php 
// the query
$the_query = new WP_Query( $args ); ?>

<?php if ( $the_query->have_posts() ) : ?>

	<!-- the loop -->
	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
		<h2><?php the_title(); ?></h2>
		<?php the_content(); ?>

	<?php endwhile; ?>
	<!-- end of the loop -->

	<!-- pagination here -->

	<?php wp_reset_postdata(); ?>

<?php else : ?>
	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Don’t forget to replace meta_key and meta_value parameters with your own values.

Add Guest Author Name Using Custom Fields

Do you want to add a guest post but don’t want to add a new user profile just to add a single post? An easier way to do that is by adding guest author name as a custom field.

First, you need to add the following code in your theme’s functions.php file or a site-specific plugin.

add_filter( 'the_author', 'guest_author_name' );
add_filter( 'get_the_author_display_name', 'guest_author_name' );
function guest_author_name( $name ) {
global $post;
$author = get_post_meta( $post->ID, 'guest-author', true );
if ( $author )
$name = $author;
return $name;
}

This code hooks a function to the_author and get_the_author_display_name filters in WordPress. The function first checks for the guest author name. If it exists, then it replaces the author name with the guest author name.

Now you will need to edit the post where you want to display the guest author name. Go to the custom fields meta box and add your guest author name.

Adding guest author custom field

For details, see our article on how to rewrite guest author name with custom fields in WordPress.

Display Contributors to an Article Using Custom Fields

On many popular blogs and news sites, multiple authors contribute to write an article. However, WordPress only allows a single author to be associated with a post.

One way to solve this problem is by using Co-Authors Plus plugin. To learn more, see our guide on how to add multiple authors on a WordPress post.

Another way to do that is by adding contributors as a custom field.

First you need to edit the post where you want to display co-authors or contributors. Scroll down to custom fields meta box and add author names as co-author custom field.

Adding co-authors as custom field

Now add this code to your theme files where you want to show co-authors.


<?php 

$coauthors = get_post_meta($post->ID, 'co-author', false);
if( count( $coauthors ) != 0 ) { ?>
<ul class="coauthors">
<li>Contributors</li>
<?php foreach($coauthors as $coauthors) { ?>
           <?php echo '<li>'.$coauthors.'</li>' ;
            }
            ?>
</ul>
<?php 
} else { 
// do nothing; 
}
?>

To display author names separated by commas, you can add the following custom CSS.

.coauthors ul { 
display:inline;
}
.coauthors li { 
display:inline;
list-style:none;
}
.coauthors li:after { 
content:","
}
.coauthors li:last-child:after {
    content: "";
}
.coauthors li:first-child:after {
    content: ":";
}

This is how it looked on our demo site.

Co-authors displayed using custom fields

Display Custom Fields Outside the Loop in WordPress

So far we have shown you all the examples where custom fields are displayed inside the WordPress loop. What if you needed to show them outside the loop? For example, in the sidebar of a single post.

To display the custom fields outside the WordPress loop add the following code:

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'key', true);
wp_reset_query();
?>

Don’t forget to replace the key with your custom field name.

Display Custom Header, Footer, Sidebar using Custom Fields

Usually most WordPress themes use the same header, footer, and sidebar on all pages. There are multiple ways to show different sidebars, header, or footer for different pages on your website. See our guide on how to display different sidebar for each WordPress post or page.

One way to do this is by using custom fields. Edit the post or page where you want to show a different sidebar and then add the sidebar as custom field.

Adding custom sidebar to a post using custom fields

Now you need to edit your WordPress theme files like single.php where you want to display custom sidebar. You will be looking for the following code:

<?php get_sidebar(); ?>

Replace this line with the following code:

<?php 
global $wp_query;
$postid = $wp_query->post->ID;
$sidebar = get_post_meta($postid, "sidebar", true);
get_sidebar($sidebar);
wp_reset_query();
?>

This code simply looks for the sidebar custom field and then displays it in your theme. For example, if you add wpbpage as your sidebar custom field, then the code will look for sidebar-wpbpage.php file to display.

You will need to create sidebar-wpbpage.php file in your theme folder. You can copy the code from your theme’s sidebar.php file as an starting point.

Manipulating RSS feed Content with Custom Fields

Want to display additional meta data or content to your RSS feed users? Using custom fields you can manipulate your WordPress RSS feed and add custom content into your feeds.

First you need to add the following code in your theme’s functions.php file or a site-specific plugin.

function wpbeginner_postrss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
$coolcustom = get_post_meta($postid, 'coolcustom', true);
if(is_feed()) {
if($coolcustom !== '') {
$content = $content."<br /><br /><div>".$coolcustom."</div>
";
}
else {
$content = $content;
}
}
return $content;
}
add_filter('the_excerpt_rss', 'wpbeginner_postrss');
add_filter('the_content', 'wpbeginner_postrss');

Now just create a custom field called “coolcustom” and add any value you like. You can use it to display advertisements, images, text, or anything you want.

Manipulate RSS Feed Title with Custom Fields

Sometimes you may want to add extra text to a post title for RSS feed users. For example, if you are publishing a sponsored post or a guest post.

First you add the following code in your theme’s functions.php file or a site-specific plugin.

function wpbeginner_titlerss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
$gpost = get_post_meta($postid, 'guest_post', true);
$spost = get_post_meta($postid, 'sponsored_post', true);

if($gpost !== '') {
$content = 'Guest Post: '.$content;
}
elseif ($spost !== ''){
$content = 'Sponsored Post: '.$content;
}
else {
$content = $content;
}
return $content;
}
add_filter('the_title_rss', 'wpbeginner_titlerss');

Next, you need to edit the post where you want to display the extra text in the title field and add guest_post and sponsored_post in custom fields.

 Sponsored and guest post custom fields

If any of these two custom fields are found with a value “true”, then it will add the appropriate text before the title. This technique can be utilized in various ways to fit whatever you like.

Want to learn more cool RSS feed hacks? See our guide on how to add content and manipulate your WordPress RSS feeds.

Set Expiration Date for Posts in WordPress Using Custom Fields

Want to set an expiration date for some posts on your WordPress site? This comes handy in situations when you want to publish content only for a specific period like running surveys or limited time offers.

One way to do this is by manually removing the post content or by using a plugin like Post Expirator plugin.

Another way to do this is by using custom fields to automatically expire posts after a specific time.

You will need to edit your theme files and add modify the WordPress loop like this:

<?php
if (have_posts()) :
while (have_posts()) : the_post(); 
$expirationtime = get_post_meta($post->ID, "expiration", false);
if( count( $expirationtime ) != '' ) { 
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}

$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween >= 0 ) {
echo 'This post will expire on ' .$expirestring.'';
the_content();
} else { 
echo "Sorry this post expired!"
}
} else { 
the_content();
} 
endwhile;
endif;
?>

Note: You will need to edit this code to match your theme.

After adding this code, you can add the expiration custom field to the post you want to expire. Make sure you add the time in this format mm/dd/yyyy 00:00:00.

Adding an expiration custom field to a WordPress post

Style Individual Posts Using Custom Fields

Want to change the look of an individual post using CSS? WordPress automatically assigns each post its own class which you can use to add custom CSS.

However, using custom fields you can add your own custom classes and then use them to style posts differently.

First you need to edit a post that you would like to style differently. Go to custom fields box and the post-class custom field.

Post class custom field

Next, you need to edit your WordPress theme files and add this code at the beginning of WordPress loop.

<?php $custom_values = get_post_meta($post->ID, 'post-class'); ?>

Now you need to find a line with the post_class() function. Here is how it looked in our demo theme:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

Change this line to include your custom field value, like this:

<article id="post-<?php the_ID(); ?>" <?php post_class($custom_values); ?>>

Now if you examine the post’s source code using Inspect tool, then you will see your custom field CSS class added to the post class.

Custom field post class

Now you can use this CSS class to add custom CSS and style your post differently.

That’s all, we hope this article helped you learn more about WordPress custom fields. You may also want to see our ultimate step by step guide to boost WordPress speed and performance for beginners.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post WordPress Custom Fields 101: Tips, Tricks, and Hacks appeared first on WPBeginner.

WordPress Custom Fields 101: Tips, Tricks, and Hacks

Ever wondered what are custom fields in WordPress? Want to learn more about how custom fields work? In this article, we will show you how to user WordPress custom fields with tips, tricks, and hacks. Since this is a lengthy article, we have added table… Read More »

The post WordPress Custom Fields 101: Tips, Tricks, and Hacks appeared first on WPBeginner.

Ever wondered what are custom fields in WordPress? Want to learn more about how custom fields work? In this article, we will show you how to user WordPress custom fields with tips, tricks, and hacks.

Custom Fields 101

Since this is a lengthy article, we have added table of contents for easier navigation.

What are WordPress Custom Fields?

WordPress custom fields are metadata that are used to add additional information related to the post or page such as title, author name, date / time, etc.

By default, when you write a new post, page, or any content type, WordPress saves it into two different areas. The first part is the body of your content that you add using the post editor.

The second part is the information about that particular content. For example, title, author, date, time, and more. This information bit of the post is called metadata.

WordPress automatically adds all the required metadata to each post or page you create. WordPress also allows users to save their own custom metadata using custom fields.

By default, custom fields option is hidden on the post edit screen. To view it, you need to click on the ‘Screen Options’ button at the top and then check the custom fields option.

Show custom fields meta box

Scroll down a little, and you will be able to see the custom field meta box below the post editor.

Custom fields meta box on post edit screen in WordPress

Custom fields can be used to add any information related to the post, page, or any content type. This meta information can be displayed in your theme. However, to do that you will need to edit your WordPress theme files.

This is why this tutorial is recommended for users familiar with editing theme files. It is also helpful for aspiring WordPress developers who want to learn how to properly use custom fields in their own themes or plugins.

Having said that, let’s take a look at how to add and use custom fields in WordPress.

Adding Custom Fields in WordPress

First you need to edit the post or page where you want to add the custom field and go to the custom fields meta box.

Adding custom field

Next, you need to provide a name for your custom field and then enter its value. Click on the Add Custom Field button to save it.

The field will be stored and displayed in the custom fields meta box like this:

Saved custom field

You can edit this custom field any time you want and then click on the update button to save your changes. You can also delete it as needed.

Now you can save your post to store your custom field settings.

Displaying Custom Fields in WordPress Themes

To display your custom field on your website, you will need to edit your WordPress theme files. If you haven’t done this before, then take a look at our guide on how to copy and paste code in WordPress.

First you will need to find the theme file you need to edit to display your custom field. Ideally you would want to display it on a single post page. You will need to edit the single.php or content-single.php file.

You will need to enter your custom fields code inside the WordPress loop. Look for the line that looks like this:

<?php while ( have_posts() ) : the_post(); ?>

You want to make sure that you add your code before the following line:

<?php endwhile; // end of the loop. ?>

Now you need to add this code to your theme file:

<?php echo get_post_meta($post->ID, 'key', true); ?>

Don’t forget to replace key with the name of your custom field. For example, we used this code in our demo theme:

<p>Today's Mood: <?php echo get_post_meta($post->ID, 'Mood', true); ?></p>

You can now save your changes and visit the post where you added the custom field to see it in action.

Custom field data displayed in a WordPress theme

Now you can use this custom field in all your other WordPress posts as well. Simply create a new post or edit an existing one. Go to the custom fields meta box and select your custom field from the drop down menu and enter its value.

Select and reuse custom field

Click on ‘Add Custom Field’ button to save your changes and then publish or update your post.

Creating a User Interface for Custom Fields

As you can see, that once you add a custom field, you will have to select the field and enter its value each time you write a post.

If you have many custom fields or multiple users writing on your website, then this is not a very ideal solution.

Wouldn’t it be nice if you could create a user interface where users can fill in a form to add values into your custom fields?

This is what so many popular plugins already do. For example, the SEO title and meta description box inside Yoast SEO plugin is a custom meta box:

Custom meta box used in Yoast SEO

The easiest way to do this is by using the Advanced Custom Fields plugin. It allows you to create custom fields, group them, and display them in a custom meta box on your post edit screens in WordPress.

For detailed step by step instructions, see our guide on how to add custom meta boxes in WordPress posts and post types.

Hide Empty Custom Fields with Conditional Statement

In the above example, we showed you how to create a custom field and display it in your theme.

Now let’s see how to check if the custom field is not empty before displaying it. To do that, we will modify our code to first check if the field has data in it.

<?php 

$mood = get_post_meta($post->ID, 'Mood', true);

if ($mood) { ?>

<p>Today's Mood: <? echo $mood; ?></p>

<?php 

} else { 
// do nothing; 
}

?>

Don’t forget to replace Mood with your own custom field name.

Adding Multiple Values to a Custom Field

Custom fields can be reused in the same post again to add multiple values. You just need to select it again and add another value.

Adding multiple values to a custom field

However, the code we have used in above examples will only be able to show a single value.

To display all values of a custom field, we need to modify the code and make it return the data in an array. You will need to add the following code in your theme file:

<?php 
$mood = get_post_meta($post->ID, 'Mood', false);
if( count( $mood ) != 0 ) { ?>
<p>Today's Mood:</p>
<ul>
<?php foreach($mood as $mood) {
            echo '<li>'.$mood.'</li>';
            }
            ?>
</ul>
<?php 
} else { 
// do nothing; 
}
?>

Don’t forget to replace Mood with your own custom field name.

In this example, you would notice that we have changed the last parameter of get_post_meta function to false. This parameter defines whether the function should return a single value or not. Setting it to false allows it to return the data as an array, which we then displayed in a foreach loop.

Displaying Posts with a Specific Custom Key

WordPress allows you to display posts with custom keys and their values. For example, if you are trying to create a custom archive page to display all posts with specific custom keys, then you can use WP_Query class to query posts matching those fields.

You can use the following code as an starting point.

$args = array(
	'meta_key'   => 'Mood',
	'meta_value' => 'Happy'
);
$the_query = new WP_Query( $args );

<?php 
// the query
$the_query = new WP_Query( $args ); ?>

<?php if ( $the_query->have_posts() ) : ?>

	<!-- the loop -->
	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
		<h2><?php the_title(); ?></h2>
		<?php the_content(); ?>

	<?php endwhile; ?>
	<!-- end of the loop -->

	<!-- pagination here -->

	<?php wp_reset_postdata(); ?>

<?php else : ?>
	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Don’t forget to replace meta_key and meta_value parameters with your own values.

Add Guest Author Name Using Custom Fields

Do you want to add a guest post but don’t want to add a new user profile just to add a single post? An easier way to do that is by adding guest author name as a custom field.

First, you need to add the following code in your theme’s functions.php file or a site-specific plugin.

add_filter( 'the_author', 'guest_author_name' );
add_filter( 'get_the_author_display_name', 'guest_author_name' );
function guest_author_name( $name ) {
global $post;
$author = get_post_meta( $post->ID, 'guest-author', true );
if ( $author )
$name = $author;
return $name;
}

This code hooks a function to the_author and get_the_author_display_name filters in WordPress. The function first checks for the guest author name. If it exists, then it replaces the author name with the guest author name.

Now you will need to edit the post where you want to display the guest author name. Go to the custom fields meta box and add your guest author name.

Adding guest author custom field

For details, see our article on how to rewrite guest author name with custom fields in WordPress.

Display Contributors to an Article Using Custom Fields

On many popular blogs and news sites, multiple authors contribute to write an article. However, WordPress only allows a single author to be associated with a post.

One way to solve this problem is by using Co-Authors Plus plugin. To learn more, see our guide on how to add multiple authors on a WordPress post.

Another way to do that is by adding contributors as a custom field.

First you need to edit the post where you want to display co-authors or contributors. Scroll down to custom fields meta box and add author names as co-author custom field.

Adding co-authors as custom field

Now add this code to your theme files where you want to show co-authors.


<?php 

$coauthors = get_post_meta($post->ID, 'co-author', false);
if( count( $coauthors ) != 0 ) { ?>
<ul class="coauthors">
<li>Contributors</li>
<?php foreach($coauthors as $coauthors) { ?>
           <?php echo '<li>'.$coauthors.'</li>' ;
            }
            ?>
</ul>
<?php 
} else { 
// do nothing; 
}
?>

To display author names separated by commas, you can add the following custom CSS.

.coauthors ul { 
display:inline;
}
.coauthors li { 
display:inline;
list-style:none;
}
.coauthors li:after { 
content:","
}
.coauthors li:last-child:after {
    content: "";
}
.coauthors li:first-child:after {
    content: ":";
}

This is how it looked on our demo site.

Co-authors displayed using custom fields

Display Custom Fields Outside the Loop in WordPress

So far we have shown you all the examples where custom fields are displayed inside the WordPress loop. What if you needed to show them outside the loop? For example, in the sidebar of a single post.

To display the custom fields outside the WordPress loop add the following code:

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'key', true);
wp_reset_query();
?>

Don’t forget to replace the key with your custom field name.

Display Custom Header, Footer, Sidebar using Custom Fields

Usually most WordPress themes use the same header, footer, and sidebar on all pages. There are multiple ways to show different sidebars, header, or footer for different pages on your website. See our guide on how to display different sidebar for each WordPress post or page.

One way to do this is by using custom fields. Edit the post or page where you want to show a different sidebar and then add the sidebar as custom field.

Adding custom sidebar to a post using custom fields

Now you need to edit your WordPress theme files like single.php where you want to display custom sidebar. You will be looking for the following code:

<?php get_sidebar(); ?>

Replace this line with the following code:

<?php 
global $wp_query;
$postid = $wp_query->post->ID;
$sidebar = get_post_meta($postid, "sidebar", true);
get_sidebar($sidebar);
wp_reset_query();
?>

This code simply looks for the sidebar custom field and then displays it in your theme. For example, if you add wpbpage as your sidebar custom field, then the code will look for sidebar-wpbpage.php file to display.

You will need to create sidebar-wpbpage.php file in your theme folder. You can copy the code from your theme’s sidebar.php file as an starting point.

Manipulating RSS feed Content with Custom Fields

Want to display additional meta data or content to your RSS feed users? Using custom fields you can manipulate your WordPress RSS feed and add custom content into your feeds.

First you need to add the following code in your theme’s functions.php file or a site-specific plugin.

function wpbeginner_postrss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
$coolcustom = get_post_meta($postid, 'coolcustom', true);
if(is_feed()) {
if($coolcustom !== '') {
$content = $content."<br /><br /><div>".$coolcustom."</div>
";
}
else {
$content = $content;
}
}
return $content;
}
add_filter('the_excerpt_rss', 'wpbeginner_postrss');
add_filter('the_content', 'wpbeginner_postrss');

Now just create a custom field called “coolcustom” and add any value you like. You can use it to display advertisements, images, text, or anything you want.

Manipulate RSS Feed Title with Custom Fields

Sometimes you may want to add extra text to a post title for RSS feed users. For example, if you are publishing a sponsored post or a guest post.

First you add the following code in your theme’s functions.php file or a site-specific plugin.

function wpbeginner_titlerss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
$gpost = get_post_meta($postid, 'guest_post', true);
$spost = get_post_meta($postid, 'sponsored_post', true);

if($gpost !== '') {
$content = 'Guest Post: '.$content;
}
elseif ($spost !== ''){
$content = 'Sponsored Post: '.$content;
}
else {
$content = $content;
}
return $content;
}
add_filter('the_title_rss', 'wpbeginner_titlerss');

Next, you need to edit the post where you want to display the extra text in the title field and add guest_post and sponsored_post in custom fields.

 Sponsored and guest post custom fields

If any of these two custom fields are found with a value “true”, then it will add the appropriate text before the title. This technique can be utilized in various ways to fit whatever you like.

Want to learn more cool RSS feed hacks? See our guide on how to add content and manipulate your WordPress RSS feeds.

Set Expiration Date for Posts in WordPress Using Custom Fields

Want to set an expiration date for some posts on your WordPress site? This comes handy in situations when you want to publish content only for a specific period like running surveys or limited time offers.

One way to do this is by manually removing the post content or by using a plugin like Post Expirator plugin.

Another way to do this is by using custom fields to automatically expire posts after a specific time.

You will need to edit your theme files and add modify the WordPress loop like this:

<?php
if (have_posts()) :
while (have_posts()) : the_post(); 
$expirationtime = get_post_meta($post->ID, "expiration", false);
if( count( $expirationtime ) != '' ) { 
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}

$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween >= 0 ) {
echo 'This post will expire on ' .$expirestring.'';
the_content();
} else { 
echo "Sorry this post expired!"
}
} else { 
the_content();
} 
endwhile;
endif;
?>

Note: You will need to edit this code to match your theme.

After adding this code, you can add the expiration custom field to the post you want to expire. Make sure you add the time in this format mm/dd/yyyy 00:00:00.

Adding an expiration custom field to a WordPress post

Style Individual Posts Using Custom Fields

Want to change the look of an individual post using CSS? WordPress automatically assigns each post its own class which you can use to add custom CSS.

However, using custom fields you can add your own custom classes and then use them to style posts differently.

First you need to edit a post that you would like to style differently. Go to custom fields box and the post-class custom field.

Post class custom field

Next, you need to edit your WordPress theme files and add this code at the beginning of WordPress loop.

<?php $custom_values = get_post_meta($post->ID, 'post-class'); ?>

Now you need to find a line with the post_class() function. Here is how it looked in our demo theme:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

Change this line to include your custom field value, like this:

<article id="post-<?php the_ID(); ?>" <?php post_class($custom_values); ?>>

Now if you examine the post’s source code using Inspect tool, then you will see your custom field CSS class added to the post class.

Custom field post class

Now you can use this CSS class to add custom CSS and style your post differently.

That’s all, we hope this article helped you learn more about WordPress custom fields. You may also want to see our ultimate step by step guide to boost WordPress speed and performance for beginners.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post WordPress Custom Fields 101: Tips, Tricks, and Hacks appeared first on WPBeginner.

How to Display Different Sidebar for Each Post and Page in WordPress

Do you want to display different sidebars for different posts and pages on your WordPress site? Typically, WordPress themes show the same sidebars on fixed locations regardless of which post or page you’re on. In this article, we will show you how to create and… Read More »

The post How to Display Different Sidebar for Each Post and Page in WordPress appeared first on WPBeginner.

Do you want to display different sidebars for different posts and pages on your WordPress site? Typically, WordPress themes show the same sidebars on fixed locations regardless of which post or page you’re on. In this article, we will show you how to create and display different sidebars for each post and pages in WordPress.

Custom Sidebars for WordPress

When Would You Need Different Sidebars in WordPress?

By default, sidebars are defined by your WordPress theme. Each WordPress theme comes with a few sidebars or widget ready areas that allow you to add widgets.

Typically a sidebar on the blog is displayed throughout your site on all posts, pages, categories, and archive pages. However, sometimes you may want your sidebar content to change based on specific posts or pages.

For example, you can show different featured content in the sidebar of your most popular posts, add different email signup forms, or display ads.

Having said that, let’s see how to create and display different sidebar for each post and page in WordPress.

Displaying Different Sidebars for Each Post and Page in WordPress

First thing you need to do is install and activate the Easy Custom Sidebars plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Appearance » Theme Sidebars page to create custom sidebars.

Creating a new custom sidebar

First you need to provide a name for your custom sidebar and then click on the create sidebar button.

The plugin will now create your sidebar, and you will be able to select the sidebar properties.

Sidebar settings

After that you need to select which theme sidebar will be replaced by your custom sidebar and provide a description for it.

Next, you need to select where you want your custom sidebar to replace the theme sidebar. You will see your posts, pages, categories and tags listed in the left column of the screen.

Simply select the areas where you want custom sidebar to be displayed and then click on ‘Add to sidebar’ button.

Add posts or pages to your custom sidebar

You will notice your selected items appear under the custom sidebar settings. Don’t forget to click on the save button to store your sidebar settings.

Easy Custom Sidebar allows you to create as many custom sidebars as you like and assign each sidebar to different pages on your WordPress site.

Adding Widgets to Your Custom Sidebars

Once you have created custom sidebars and assigned them to different areas of your website, it’s time to add widgets to your sidebars.

Head over to the Appearance » Widgets page. You will notice your newly created custom sidebars among your theme’s default sidebars.

Add widgets to custom sidebar

You can go ahead and add widgets to your custom sidebars. The plugin will now show the sidebars based on your settings. You can visit your selected pages to see it in action.

We hope this article helped you learn how to add different sidebars to each post or page in WordPress. You may also want to see our these WordPress sidebar tricks to get maximum results.

The post How to Display Different Sidebar for Each Post and Page in WordPress appeared first on WPBeginner.

Get Solarized – Awesome command prompt colors for VS, VS Code, cmd, PowerShell, and more

imageI was on a call with my co-worker Maria today and she commented on how nice my command prompt in Windows looked. I told it was “Solarized” and then our conference call fell apart as we collected all kinds of fun info about how you can get Solarized in your favorite apps on Windows.

Solarized is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It’s by Ethan Schoonover and it’s spread all over the web. You can see screenshots and learn about it on GitHub.

Solarized for your Windows Command Prompt (cmd, powershell, bash)

By default when you right click and hit properties on a shortcut for a prompt like cmd, powershell, or bash, you’ll get a dialog that looks like this.

Default Colors in CMD

You’ll see there’s 16 colors, usually 8 colors on the left, and then the “light/intense/bold” version of each color on the right. I usually used Intense Terminal Green on black before Solarized.

Those values (the defaults) are stored in the registry here HKEY_CURRENT_USER\Console

Where default colors are stored in the Registry

Those defaults are used for NEW shortcuts or consoles that start afresh, via Windows+R. This won’t change existing shortcuts you may already have created. There’s a few ways to fix this.

I’ve found the easiest manual way is to recreate the shortcuts. You can do this by just copy-pasting a shortcut and using the new one.

However, there is talk of programmatically updating .lnk (Start Menu link files) with PowerShell.

You’d just go to the location of each LNK file you want to change, then run Update-Link.ps1 YOURLINK.LNK “light|dark” and it’ll load up the .lnk file using Windows APIs and save it with a new Color Table.

I’ve started that work here and I’ll PR the main repo if I can solve one issue – I can’t get it to switch to Solarized Light, just Dark. It might be something wrong on my side. Please take a look if you’re a Win32/PowerShell internals type.

Here I went to where the Start Menu stores most of the LNK files. You can also search for an item in your start and right-click “Open File Location.”pow

Programatically Update your LNKs with PowerShell

Here’s before and after with my Developer Command Prompt for Visual Studio 2015.

Solarized!

NOTE: Once this is done, in cmd.exe you can also switch between light and dark with “color f6” or “color 01” which is nice for presentations. I’m not sure how to do this yet in PowerShell or Bash.

Here is the palette after:

Solarized Palette

For PowerShell there is also an extra-step you’ll want to put into your Microsoft.PowerShell_profile.ps1 where you map things like Errors, Progress Bars, and Warnings internally in PowerShell. Be sure to read the instructions.

Solarized in Visual Studio and Visual Studio Code

As for Visual Studio and Visual Studio Code, they’re far easier. You can just Ctrl-K then Ctrl-T in VSCode and pick Solarized.

Solarized in VS Code

For Visual Studio (all versions) you can head over to @leddt’s GitHub and download settings files for Solarized that you can then import info VS from Tools | Import and Export Settings.


Sponsor: Big thanks to Raygun! Don’t rely on your users to report the problems they experience. Automatically detect, diagnose and understand the root cause of errors, crashes and performance issues in your web and mobile apps. Learn more.


© 2017 Scott Hanselman. All rights reserved.
     

imageI was on a call with my co-worker Maria today and she commented on how nice my command prompt in Windows looked. I told it was "Solarized" and then our conference call fell apart as we collected all kinds of fun info about how you can get Solarized in your favorite apps on Windows.

Solarized is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It's by Ethan Schoonover and it's spread all over the web. You can see screenshots and learn about it on GitHub.

Solarized for your Windows Command Prompt (cmd, powershell, bash)

By default when you right click and hit properties on a shortcut for a prompt like cmd, powershell, or bash, you'll get a dialog that looks like this.

Default Colors in CMD

You'll see there's 16 colors, usually 8 colors on the left, and then the "light/intense/bold" version of each color on the right. I usually used Intense Terminal Green on black before Solarized.

Those values (the defaults) are stored in the registry here HKEY_CURRENT_USER\Console

Where default colors are stored in the Registry

Those defaults are used for NEW shortcuts or consoles that start afresh, via Windows+R. This won't change existing shortcuts you may already have created. There's a few ways to fix this.

I've found the easiest manual way is to recreate the shortcuts. You can do this by just copy-pasting a shortcut and using the new one.

However, there is talk of programmatically updating .lnk (Start Menu link files) with PowerShell.

You'd just go to the location of each LNK file you want to change, then run Update-Link.ps1 YOURLINK.LNK "light|dark" and it'll load up the .lnk file using Windows APIs and save it with a new Color Table.

I've started that work here and I'll PR the main repo if I can solve one issue - I can't get it to switch to Solarized Light, just Dark. It might be something wrong on my side. Please take a look if you're a Win32/PowerShell internals type.

Here I went to where the Start Menu stores most of the LNK files. You can also search for an item in your start and right-click "Open File Location."pow

Programatically Update your LNKs with PowerShell

Here's before and after with my Developer Command Prompt for Visual Studio 2015.

Solarized!

NOTE: Once this is done, in cmd.exe you can also switch between light and dark with "color f6" or "color 01" which is nice for presentations. I'm not sure how to do this yet in PowerShell or Bash.

Here is the palette after:

Solarized Palette

For PowerShell there is also an extra-step you'll want to put into your Microsoft.PowerShell_profile.ps1 where you map things like Errors, Progress Bars, and Warnings internally in PowerShell. Be sure to read the instructions.

Solarized in Visual Studio and Visual Studio Code

As for Visual Studio and Visual Studio Code, they're far easier. You can just Ctrl-K then Ctrl-T in VSCode and pick Solarized.

Solarized in VS Code

For Visual Studio (all versions) you can head over to @leddt's GitHub and download settings files for Solarized that you can then import info VS from Tools | Import and Export Settings.


Sponsor: Big thanks to Raygun! Don't rely on your users to report the problems they experience. Automatically detect, diagnose and understand the root cause of errors, crashes and performance issues in your web and mobile apps. Learn more.


© 2017 Scott Hanselman. All rights reserved.