Get author full name

Try the following: <?php $fname = get_the_author_meta(‘first_name’); $lname = get_the_author_meta(‘last_name’); $full_name=””; if( empty($fname)){ $full_name = $lname; } elseif( empty( $lname )){ $full_name = $fname; } else { //both first name and last name are present $full_name = “{$fname} {$lname}”; } echo $full_name; ?>

WordPress PHP version requirements

WordPress will change its requirements to use a higher version of PHP when the following cases are met: A significant majority of users are running 5.3.0 or above A major release cycle release approaches The code/lead developers involved all agree the above two are fulfilled Sadly, the first entry results in a vicious loop, and … Read more

PHP code on Visual Composer Plugin

So i found the answer with the help of Pieter Goosen and i would like to share it with you: A good method will be to create a Shortcode. To do it, just go to your template Functions.php file and create your function like this example: function shortcode_hello( $atts ){ $time = ( date(‘G’) < … Read more

PHP Catchable fatal error: Object of class WP_Error could not be converted to string

Line 58 as the error indicates is this line: $parent_term = get_term_by(‘ID’,$term_id, $taxonomy); $term_parents = $delimiter.”<a href=\””.get_term_link($parent_term->slug,$taxonomy).”\” title=\””. $parent_term->name .”\” >”. $parent_term->name .”</a>” .$child_terms; And our error is: Object of class WP_Error could not be converted to string Which means that one of those things being appended is not a “string”, but actually a WP_Error … Read more

Multiple is_page() in page.php

You can pass an array of IDs to is_page instead of using multiple is_page: if( is_page( array( 11, 22, 33, 44 ) ) ) { // Your code } Also, if you are using it in a loop, you should consider this note: Due to certain global variables being overwritten during The Loop, is_page() will … Read more

Query menu_order custom post types

I’ve just had to do the same thing as you, here is what I did to get this working: ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘page-attributes’) Register the post type with supports of page attributes. This adds the menu order meta box to the edit screen. From there you can place the order. Then run my … Read more

How do I use Shortcodes inside of HTML tags?

Hope this helps someone: Instead of doing this: <a href=”https://example.com/folder/edit.php?action=someaction&id=[foocode parameter=”value”]&edittoken=[foocode parameter=”othervalue”]”>linktext</a> You can do this: [foocode parameter1=value parameter2=othervalue] and then do this: add_shortcode( ‘foocode’, ‘prefix_foocode’ ); function prefix_foocode( $atts ) { // Normalize $atts, set defaults and do whatever you want with $atts. $html=”<a href=”https://example.com/folder/edit.php?action=someaction&id=” . $atts[‘parameter1′] .’&edittoken=’ . $atts[‘parameter2’] . ‘”>linktext</a>’; return $html; … Read more

How to Add Custom Fields to Custom Taxonomies in WordPress CLEANLY

Option 2 is the cleanest method – which I’ve also used a number of times. Unfortunately, there is no default term_metadata table in WordPress yet. This post also covers the same approach, http://shibashake.com/wordpress-theme/add-term-or-taxonomy-meta-data And of course, there’s a plugin for that too 🙂 http://wordpress.org/extend/plugins/taxonomy-metadata/