taylor11
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoI don’t either, but the person I am doing the project for seems to have this issue in his naming structure.
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoOther than page ID, nothing.
I can search for a tag and add something that differentiates the pages, if something exist.
Can we use the page slug?
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoGot everything working smoothly with this code, I probably should not have used another ereg_replace to remove the leftover “amp” from “&” but it is working as expected.
<?php $imgtype = '.png'; // Image type, be sure to remember the period $directory = 'wp-content/test/'; // Where your files are located $ptitle = the_title('','',false); // The title, return=false so not to echo/return value $logo = ereg_replace('[^A-Za-z0-9]', '', $ptitle ); // Remove all special characters $logo = ereg_replace('amp', '', $logo ); // Remove the remaining "amp" from "&" $logoresult = get_bloginfo('siteurl').'/'.$directory.$logo.$imgtype; // Build a complete path for image src $logodefault = get_bloginfo('siteurl').'/'.$directory.'default'.$imgtype; // Default image $logocheck = $directory.$logo.$imgtype; // Pure relative path for file_exists function $file = file_exists($logocheck); ?> <?php if($file) : // If the file exists ... ?> <img src="<?php print $logoresult; ?>" alt="<?php print $ptitle; ?>" /> <?php else : // If the file does not exist, use default ... ?> <img src="<?php print $logodefault; ?>" alt="<?php print $ptitle; ?>" /> <?php endif; ?>
Any thoughts on my other issue of the same page name but different logos need to be displayed? Your opinion may help get the ball rolling – would like to avoid using different page templates for these pages.
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoJust tried it – I have been playing with this code all day. It is nearly exactly the same as you just provided. I was using str_replace
$imgtype = '.png'; // Image type, be sure to remember the period $directory = 'wp-content/test/'; // Where your files are located $ptitle = the_title('','',false); // The title, return=false so not to echo/return value $logo = str_replace('[^a-zA-Z0-9]', '', $ptitle ); $logoresult = get_bloginfo('siteurl').'/'.$directory.$logo.$imgtype; // Build a complete path for image src $logodefault = get_bloginfo('siteurl').'/'.$directory.'default'.$imgtype; // Default image $logocheck = $directory.$logo.$imgtype; // Pure relative path for file_exists function $file = file_exists($logocheck); ?> <?php if($file) : // If the file exists ... ?> <img src="<?php print $logoresult; ?>" alt="<?php print $ptitle; ?>" /> <?php else : // If the file does not exist, use default ... ?> <img src="<?php print $logodefault; ?>" alt="<?php print $ptitle; ?>" /> <?php endif; ?>
I have no idea what is hanging it up! Been at it all day!
I also have another issue you may be able to guide me with. I have 11 pages that are the same page name. Five of the pages with the same page name use a logo with a tagline, and six of the pages with the same page name use a logo without a tagline. To make a long story short, there are 11 pages with the same page name (Store name) and they share two different logos. Any ideas? I know I can hard code it and set it to use a special template, but it would be awesome if I could just have one template that handled it all!
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoAnyone have any ideas for this one based on t31os’s code?
Ultimately would like to remove all characters except digits and alphabetical characters
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoOne last thing. I am having trouble with.
I’m attempting to use your same technique with preg_match to remove any apostrophes as well.
I am having trouble getting it to output. Can this be easily accomplished?
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoWow! Worked flawlessly.
This script combined with a gallery function will be perfect!
I appreciate all your hard work.
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoThank you.
Removing the spaces from the page title would be great. I was going to name the images according to a logo descriptor, but naming them by the page title will be logical as well. What happens if I have two locaton names(page titles) that are the same and each logo(image) is slightly different?
I greatly appreciate your effort!
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoThese are pages, not post.
Here is the code I am currently using, and it is working quite well. (Ignore that I don’t have “alt” tag)
<?php if(is_page('Page Title')) { ?> <img src="/path/to/image.png" /> <?php } elseif (is_page('Page Title')) { ?> <img src="/path/to/image.png" /> <?php } ?>
What I don’t like about doing this is that it is calling from the template file, making it rather messy. I will have to have 120 of these Conditionals to make it do exactly what I need.
Forum: Themes and Templates
In reply to: Function to search page title and generate a logoYou hit it right on the head.
By
you’d need to check for the existence of spaces etc.
do you mean spaces in the image name like…
some/path/to/image/hello this is my image.jpg?