WordPress – bbird.me http://bbird.me WordPress quick tips Wed, 08 Aug 2018 16:39:07 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 How to cut the title after certain number of characters http://bbird.me/cut-title-certain-number-characters/ http://bbird.me/cut-title-certain-number-characters/#respond Mon, 13 Feb 2017 10:33:47 +0000 http://bbird.me/?p=631 You probably know that in WordPress, for any kind of data (for example, page or post title, or post category…),

Post How to cut the title after certain number of characters je prvi puta viđen na bbird.me.

]]>
You probably know that in WordPress, for any kind of data (for example, page or post title, or post category…), you can either use the function which displays any of these data (for example the_title()), or you can only get the value (get_the_title()) without echoing and then use that value so you could apply some additional functions. 

One of the great applications of this is when you need to cut the title so it could fit into the container. What kind of scenario am I talking about? For example, if you created a theme where you have columns and would like to limit the number of characters so that huge title or description does not push one element few pixels down, making the whole thing look uneven.

Even though you can always use some JavaScript code, allowing you to calculate the height of the highest column and then apply that CSS to all the columns, perhaps in some situations a better idea is to cut the title or description.

The reason for this is that if the title or content is really huge, you would have lots of empty space within other blocks, not much to the benefit of design.

Let me show you how you can easily trim the title (and you could apply this to any type of content).

$title_pr = get_the_title();		
if (strlen($title_pr) <=63) {
  echo $title_pr;
} else {
  echo substr($title_pr, 0, 63) . '...';
}

In case you’re asking why did I use strlen(), the reason is that I don’t want to have “…” if the title is shorter than desired number of characters (in this case 63).

 

Post How to cut the title after certain number of characters je prvi puta viđen na bbird.me.

]]>
http://bbird.me/cut-title-certain-number-characters/feed/ 0
How to password protect all posts within post type http://bbird.me/password-protect-posts-within-post-type/ http://bbird.me/password-protect-posts-within-post-type/#respond Fri, 20 Jan 2017 12:27:17 +0000 http://bbird.me/?p=617 If you want to protect all posts within selected post type (for example all products), you can try my Bulk

Post How to password protect all posts within post type je prvi puta viđen na bbird.me.

]]>
If you want to protect all posts within selected post type (for example all products), you can try my Bulk Password Protect Post Types plugin. I published this plugin few days ago and it allows you to choose one or more post types and set password for all posts within.

If you like it, feel free to rate it on WordPress.org or share. If you have a suggestion on how it can be improved, I’d appreciate if you could do that.

Post How to password protect all posts within post type je prvi puta viđen na bbird.me.

]]>
http://bbird.me/password-protect-posts-within-post-type/feed/ 0
Download working WordPress “X | The Theme” child theme http://bbird.me/download-working-wordpress-x-the-theme-child-theme/ http://bbird.me/download-working-wordpress-x-the-theme-child-theme/#respond Sat, 07 Jan 2017 13:13:31 +0000 http://bbird.me/?p=587 Ever had a project where you had to create a child theme for WordPress “X | The Theme” but you

Post Download working WordPress “X | The Theme” child theme je prvi puta viđen na bbird.me.

]]>
Ever had a project where you had to create a child theme for WordPress “X | The Theme” but you didn’t have the original child theme available?

If you used any of the child theme configurators, there is a big chance that child theme didn’t work or didn’t import styles.

In that case, don’t hesitate to download this child theme which should work 🙂

Post Download working WordPress “X | The Theme” child theme je prvi puta viđen na bbird.me.

]]>
http://bbird.me/download-working-wordpress-x-the-theme-child-theme/feed/ 0
fullPage.js and Advanced Custom Fields integration http://bbird.me/fullpage-js-advanced-custom-fields-integration/ http://bbird.me/fullpage-js-advanced-custom-fields-integration/#respond Fri, 16 Sep 2016 14:28:45 +0000 http://bbird.me/?p=557 fullPage.js is an immensely powerful free jQuery-based JavaScript library, offering (as the name suggests) an ability to create very attractive, dynamic

Post fullPage.js and Advanced Custom Fields integration je prvi puta viđen na bbird.me.

]]>
fullPage.js is an immensely powerful free jQuery-based JavaScript library, offering (as the name suggests) an ability to create very attractive, dynamic and responsive full-screen scrolling websites. The library was created by Spanish developer Álvaro Trigo and it is being used by some of the world’s top brands.

Read the full post here!

Post fullPage.js and Advanced Custom Fields integration je prvi puta viđen na bbird.me.

]]>
http://bbird.me/fullpage-js-advanced-custom-fields-integration/feed/ 0
Purging a stubborn WP Engine CSS cache http://bbird.me/purging-stubborn-wp-engine-css-cache/ http://bbird.me/purging-stubborn-wp-engine-css-cache/#comments Tue, 13 Sep 2016 18:25:36 +0000 http://bbird.me/?p=549 Here is the scenario – you created that awesome CSS and are dying to get it online. The client also.

Post Purging a stubborn WP Engine CSS cache je prvi puta viđen na bbird.me.

]]>
Here is the scenario – you created that awesome CSS and are dying to get it online. The client also. The website is hosted on WP Engine and is using its famous aggressive caching mechanism. You save the changes into style.css or elsewhere and clear the cache. But you still see the old style.css. You do it again and again and again and that old style.css is still there.

But I’ve got a quick trick for you – version your file! As you already know, the proper way to enqueue style or script in WordPress is the following:

wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( ), '1.0.0');

The number 1.0.0 is the style version which is not always included. If you want to make sure that after every cache purging the new version is loaded, you only have to change the version number. So if you put something like:

wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( ), '1.0.1');

after you have added new changes into style.css and if clear the cache after that, the new CSS version will be loaded immediately and a ton of your nerves (and your clients’ nerves) will be saved.

You’re welcome!

(yes, this happened to me, well, countless times…)

Post Purging a stubborn WP Engine CSS cache je prvi puta viđen na bbird.me.

]]>
http://bbird.me/purging-stubborn-wp-engine-css-cache/feed/ 2
How to translate theme strings using Polylang http://bbird.me/translate-theme-strings-using-polylang/ http://bbird.me/translate-theme-strings-using-polylang/#respond Thu, 08 Sep 2016 21:13:31 +0000 http://bbird.me/?p=544 One of the powerful (or let’s say useful) functions that ship with WMPL is ICL_LANGUAGE_CODE, allowing you to translate strings using PHP

Post How to translate theme strings using Polylang je prvi puta viđen na bbird.me.

]]>
One of the powerful (or let’s say useful) functions that ship with WMPL iICL_LANGUAGE_CODE, allowing you to translate strings using PHP conditional check. This is particularly useful for translating widgets and some other theme translations.

But if you’re not inclined to purchase WMPL, but still need this feature, I only found it within Polylang plugin (when talking about free WordPress plugins). The plugin itself comes with very useful and generous function reference where you will also find the following function

pll_current_language($value);

This function returns the current language, making it useful in the following way:

<?php $currentlang = pll_current_language();
if($currentlang=="en"):?>
    <h1>ENGLISH</h1>
<?php elseif($currentlang=="ar"):?>
    <h1>ARABIC</h1>
<?php endif; ?>

This allows you to create your own conditions based on current language code, making Polylang great free alternative to WPML.

Post How to translate theme strings using Polylang je prvi puta viđen na bbird.me.

]]>
http://bbird.me/translate-theme-strings-using-polylang/feed/ 0
Checking condition if on a custom post type singular or custom post type archive http://bbird.me/checking-condition-if-on-a-custom-post-type-singular-or-custom-post-type-archive/ http://bbird.me/checking-condition-if-on-a-custom-post-type-singular-or-custom-post-type-archive/#respond Thu, 08 Sep 2016 20:39:19 +0000 http://bbird.me/?p=541 If you want to check if you are on custom post type singular or custom post type archive within your

Post Checking condition if on a custom post type singular or custom post type archive je prvi puta viđen na bbird.me.

]]>
If you want to check if you are on custom post type singular or custom post type archive within your WordPress website, you can perform the following check:

<?php 
    
    if ( is_singular( 'locations' ) ||  is_post_type_archive('locations')  ) { 
    // we are on locations CPT 	
    } 
	
	else

	 {    
 	   // we are everywhere else
     }

?>

In this particular case, we are checking if we are on locations custom post type or on the archive of that CPT.

 

Post Checking condition if on a custom post type singular or custom post type archive je prvi puta viđen na bbird.me.

]]>
http://bbird.me/checking-condition-if-on-a-custom-post-type-singular-or-custom-post-type-archive/feed/ 0
How to disable (and replace) Visual Composer lightbox http://bbird.me/disable-replace-visual-composer-lightbox/ http://bbird.me/disable-replace-visual-composer-lightbox/#comments Tue, 06 Sep 2016 08:47:52 +0000 http://bbird.me/?p=537 One of the reasons you might want to replace Visual Composer lightbox (it is using prettyPhoto actually) is because of

Post How to disable (and replace) Visual Composer lightbox je prvi puta viđen na bbird.me.

]]>
One of the reasons you might want to replace Visual Composer lightbox (it is using prettyPhoto actually) is because of the mobile view where images opened using the effect are so small that you can hardly see or scroll through them.

Several people have asked about this on official Visual Composer website, but they only gave short answers which may be difficult to grasp for whoever isn’t a programmer. In short, this is how you do it – please note that this works for versions up to 4.x.x so if this is not working for versions 5.x.x (version 5 is not yet released as of this writing, nor there are any special information about it, but just to be on the safe side), feel free to post in the comments so I could remove this article. But until then, I hope some of you will find it useful.

So this is how it goes:

First, you’ll want to put the following code into functions.php of your parent or child theme:

function remove_vc_scripts(){
wp_enqueue_script('prettyphoto' );
wp_deregister_script('prettyphoto' );
}

add_action( 'wp_enqueue_scripts', 'remove_vc_scripts', 100 );

After you have done it, prettyPhoto is disabled. Now it’s time to pick another lightbox and this is one of the solutions I definitely recommend – Responsive Lightbox by dFactory. But given that VC adds rel=”prettyPhoto” attribute, you’ll want to set the new lightbox like this, making sure that you name the correct Selector:

That’s it!

Post How to disable (and replace) Visual Composer lightbox je prvi puta viđen na bbird.me.

]]>
http://bbird.me/disable-replace-visual-composer-lightbox/feed/ 23
How to separate WordPress loop into sections http://bbird.me/how-to-separate-wordpress-loop-into-sections/ http://bbird.me/how-to-separate-wordpress-loop-into-sections/#respond Wed, 29 Jun 2016 08:53:16 +0000 http://bbird.me/?p=531 In one of my recent projects, the client wanted to create a homepage with several different layouts for groups of

Post How to separate WordPress loop into sections je prvi puta viđen na bbird.me.

]]>
In one of my recent projects, the client wanted to create a homepage with several different layouts for groups of posts. Normally this is not a problem – you can just create several loops, reset them, and you can get any imaginable layout. But this was a different pair of boots – the homepage consisted of several sections, with widget areas in between, while each section (there were three sections of posts) had a different layout. Moreover, the second and every other page of posts had a different layout again. I’m sure there are couple of ways to achieve this, but I found the method with counter as the most convenient one.

In my example below, you will find some registered widget areas and some classes that were specific for this project. Also, on the first page, I set a different number of posts on the homepage and for the other pages. In any case, here is the code, feel free to use it if you find any of use of it 🙂

Post How to separate WordPress loop into sections je prvi puta viđen na bbird.me.

]]>
http://bbird.me/how-to-separate-wordpress-loop-into-sections/feed/ 0
How to retrieve featured image URL in WordPress http://bbird.me/retrieve-featured-image-url-wordpress/ http://bbird.me/retrieve-featured-image-url-wordpress/#respond Tue, 07 Jun 2016 12:28:18 +0000 http://bbird.me/?p=502 If (for some reason) you have the need to get the featured image (or post thumbnail) URL, you can do

Post How to retrieve featured image URL in WordPress je prvi puta viđen na bbird.me.

]]>
If (for some reason) you have the need to get the featured image (or post thumbnail) URL, you can do it with wp_get_attachment_image_src() function, for example like this:

<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID, 'full' ), 'single-post-thumbnail' ); ?>
<div id="custom-bg" style="background-image: url('<?php echo $image[0]; ?>')">
<?php endif; ?>
</div>

 

Post How to retrieve featured image URL in WordPress je prvi puta viđen na bbird.me.

]]>
http://bbird.me/retrieve-featured-image-url-wordpress/feed/ 0