How to use custom post type archive as front page

We can easily set any page as front page from Settings > Reading. It can be any static page. But what if we want to set an archive or CPT archive page as front page? There are many ways to do so. We can create a custom page template, and write our code to get the posts for the post type (will look like an archive). Then create a wordpress page using that page template and select that page as front page from Settings > Reading. This is a little complex if you are not a developer. Or even if […]

Continue Reading

You may also like

Defer parsing of javascript to improve performance in wordpress

Nothing for introduction, hehe! A very small snippet which will help you to defer parsing all javascript files except jquery in wordpress. Here is the code: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', […]

Continue Reading

You may also like

Why you shouldn’t use one click installer to install wordpress

Yes, you will fall at the mid-ocean, trust me! Well, most of the bloggers just maintain a simple blog so usually they don’t need to worry. They just need to keep a regular backup. But if you are planning to run a business site in wordpress and if that site is your everything, never ever use one click installer to install wordpress! You’d be better off installing it manually which may take you a few minutes longer to install. Here you can get an idea about manually installing wordpress: codex.wordpress.org/Installing_WordPress www.siteground.com/tutorials/wordpress/wordpress-installation.htm If you want to install manually, download wordpress from […]

Continue Reading

You may also like

How to convert hexadecimal color value to RGB value in php

Most of the CMS provides a color picker in admin panel to user to choose a color. And almost all of the color pickers return the color code as hexadecimal mode, e.g. #4EE4D3. So, you can just get the value and set the color in css. For example: [php] body{ background: } [/php] This is a very good practice. Problem occurs if you want to put a opacity option to the user. You can set background opacity with hexadecimal color value. You must use RGBA filter, so RGB color mode as well. Like: [css] body{ background: rgba(233, 122, 234, 0.7); […]

Continue Reading

You may also like

Get current page url in php

In an application, sometimes we need to get the current page URL in php. I mean, the URL shown in the browser. Here is how you can do it. First, we will declare and use the function as the following: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function current_page_url() { $url = 'http'; if ($_SERVER["HTTPS"] == "on") $url .= "s"; $url .= "://"; if ($_SERVER["SERVER_PORT"] != "80") […]

Continue Reading

You may also like

Reorder or rearrange buddypress menu items

Don’t like the order of BuddyPress menu items? Change it! Use the following code and organize in your way – how you want to reorder the BuddyPress menu items. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function my_change_profile_tab_order() { global $bp; $bp->bp_nav['settings']['position'] = 10; $bp->bp_nav['activity']['position'] = 20; $bp->bp_nav['friends']['position'] = 30; $bp->bp_nav['groups']['position'] = 40; $bp->bp_nav['blogs']['position'] = 50; $bp->bp_nav['messages']['position'] = 60; $bp->bp_nav['profile']['position'] = 70; } add_action( ‘bp_setup_nav’, ‘my_change_profile_tab_order’, 999 […]

Continue Reading

You may also like

Get All posts by tag in a network – wordpress multisite

If you want to show some selected posts as popular posts across the network, then this snippet is for you You can fetch posts by any tag that is available in your wordpress multisite network and show those to anywhere, maybe in the main site or in any subsite. If you want to show posts from some selected subsites, you just need to pass those blog IDs as an array parameter or if you send an empty parameter it will fetch posts from all subsites in the network. Here is the code: This file contains bidirectional Unicode text that may […]

Continue Reading

You may also like

Show posts based on user preference in wordpress

This is an interesting snippet that will help you to set a preference for the users, so that they will choose their favorite categories and they will see posts from these categories only. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php add_action( 'show_user_profile', 'extra_fields' ); add_action( 'edit_user_profile', 'extra_fields' ); add_action( 'personal_options_update', 'save_fields' ); add_action( 'edit_user_profile_update', 'save_fields' ); add_action( 'pre_get_posts', 'exclude_category' ); function extra_fields($user) { $pref_cat = explode( ',', […]

Continue Reading

You may also like

Remove joined group notification from sitewide activity

This is very little code snippet that will help you to hide some activity notification from the sitewide activity page. When someone joins in a group, we see a notification in sitewide activity page says, “Someone joined the group ABC”. This not that bad, but if your site is attacked by spam users, your activity feed will be flooded with spam notification. So why don’t just hide it? Here is the code snippet: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals […]

Continue Reading

You may also like

How to write dynamic css in a php file in wordpress

It’s always standard to maintain a separate css file for styling, even for dynamic css that is generated by the theme options. Most of the theme developers include this dynamic styles into the header or footer using wp_head or wp_footer hook. How’s about having a totally separate css file for the dynamic styles? It’s pretty simple so let’s start! In my example, I have used redux framework, so that I have a global variable. In my case, I assume my global variable is $lts. So, in functions.php you need to add like this: [php] // Adding custom script add_action( ‘wp_enqueue_scripts’, […]

Continue Reading

You may also like

1 2 3 8