bloginfo(‘template_directory’) img src

You cannot use bloginfo() while your are outputting using echo because bloginfo it self also out puts string using echo. Below will work for you, you also have extra double quote which i have removed…. <?php $attch_id_1 = pn_get_attachment_id_from_url(get_post_meta($post->ID, ‘img1’, true)); $image_attributes_1 = wp_get_attachment_image_src( $attch_id_1, ‘full’); $attch_id_2 = pn_get_attachment_id_from_url(get_post_meta($post->ID, ‘img2’, true)); $image_attributes_2 = wp_get_attachment_image_src( $attch_id_2, … Read more

How do I create a dynamically-updated copyright statement?

Here’s what I use: function oenology_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(” SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status=”publish” “); $output=””; if($copyright_dates) { $copyright = “&copy; ” . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= ‘-‘ . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; } Of course, if there’s a … Read more

Is it possible to change the template_directory?

You can filter template_directory_uri: <?php add_filter( ‘template_directory_uri’, function( $template_dir_uri ){ return str_replace( ‘http://example.com’, ‘https://cdn.example.com’, $template_dir_uri ); }); This will change URIs so they point at a CDN subdomain served via HTTPS.

Filter the blog’s title without using global variables

You can encapsulate the logic in a class: class NameSwitch { private $state = false; private $string; public function __construct( $string ) { $this->string = $string; } public function change_state() { $this->state = ! $this->state; return $this->state; } public function replace( $output, $show = NULL ) { if ( ‘name’ !== $show ) return $output; … Read more

Filter the blog title displayed in the header

Remove that filter/function and apply your markup in the PHP template/page file. If you need help post where you output the title. CLASS Here is how I might set this up using a class: if ( ! class_exists( ‘ThemeCustomizations’ ) ) { class ThemeCustomizations { static $inBody = false; public static function set_in_body_true() { static::$inBody … Read more

How to use tinyMCE for user “biographical info” without messing with any core file?

Not sure if this is the perfect way to do it, but it worked for me by removing the description element using jQuery and then adding editor for the description element. /******************************************* * TinyMCE EDITOR “Biographical Info” USER PROFILE *******************************************/ function biographical_info_tinymce() { if ( basename($_SERVER[‘PHP_SELF’]) == ‘profile.php’ || basename($_SERVER[‘PHP_SELF’]) == ‘user-edit.php’ && function_exists(‘wp_tiny_mce’) ) … Read more

bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()

get_stylesheet_directory_uri() returns a value, it doesn’t print anything. So you have to use: echo get_stylesheet_directory_uri(); get_template_part() is just a wrapper for locate_template(). But the latter has one advantage: It returns the path of the file it has found. Try the following: $path = locate_template( ‘sidebar-front.php’, TRUE ); echo $path;

get_template_directory_uri() and other URL tags not working in theme

What you have: <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/46261/<?php echo get_template_directory_uri(); ?>/css/style.css”> should work fine. I’ve copied and pasted into my header.php and it worked. But this is not how you should be including css or javascript files. The proper way is to use the wp_enqueue_scripts hook. For instance, say you have javascript file you wish to load … Read more