siegetheartist
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: How do I pull an image from a post and display it on a page?Mr Shane Gowland, you are a gentleman and a scholar. : )
I can attest that the above code works as intended and without errors. Thank you for your help. I sincerely appreciate your time in helping me resolve this problem.
Forum: Fixing WordPress
In reply to: How do I pull an image from a post and display it on a page?I entered this code in the function.php as stated
function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; }Then modified the code that goes in the static page to this:
echo('<img src=". catch_that_image() . "/>') ?>And nothing happens. Now, not even the file path is displaying. Nothing displays.
Forum: Fixing WordPress
In reply to: How do I pull an image from a post and display it on a page?Thank you Shane. I found that post earlier too. For some reason (for me) instead of displaying the images, it displays the file path of the image. I don’t know how to fix it. Haha. Any ideas?
Forum: Fixing WordPress
In reply to: How do I pull an image from a post and display it on a page?Figured out how to change the thumbnails default size.
the_post_thumbnail( array(600,248) );Great resource: http://codex.wordpress.org/Post_Thumbnails
Still trying to find a function that will grab an image in a post, and display it on a themes page without resorting to using featured images.
Forum: Fixing WordPress
In reply to: How do I pull an image from a post and display it on a page?Thank you for your suggestion. This is a wonderful method to achieve said result, but I want to make it “dummy” proof. If a client forgets to add the featured picture, then it wont show up. : (
So I figure I need a function that checks the post for an image, grabs that image, then I can call that function in the loop on the themes file. Any suggestions?
Also, the post thumbnail method creates a thumbnail. Is there anyway to make it display in its full size rather than a thumbnail?
Thank you for your help
Forum: Fixing WordPress
In reply to: How do you get jQuery to work in WordPress?Any ideas?
Forum: Fixing WordPress
In reply to: How do you get jQuery to work in WordPress?I am trying to create a simple image gallery.
I have a bunch of anchor tags that need its browser behavior modified by jquery so that instead of opening up the image link in a new tab, it loads the picture in a container on the same page.
This is how my functions.php currently looks like
// Load jQuery if ( !is_admin() ) { wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"), false); wp_enqueue_script('jquery'); } wp_register_script('portfolio_gallery_js', get_bloginfo('template_directory') . "/js/gallery.js"); wp_enqueue_script('portfolio_gallery_js');And this is how my .js file looks like:
// JavaScript Document jQuery(document).ready(function(){ jQuery('.thumbnail_image a').click(function(e){ e.preventDefault(); jQuery('.thumbnail_image a').removeClass('selected'); jQuery('.thumbnail_image a').children().css('opacity', '1'); jQuery(this).addClass('selected'); jQuery(this).children().css('opacity','.4'); // Sets up variables based on linked thumbnails var photo_caption = jQuery(this).attr('title'); var photo_fullsize = jQuery(this).attr('href'); var photo_preview = photo_fullsize.replace('_fullsize', '_preview'); jQuery('.selected_image').html('<a href="'+photo_fullsize+'" title="'+photo_caption+'" style="background-image:url('+photo_preview+');"></a>'); }); });I thought that the current functions.php is already getting jquery because when I do a “view source” on the page I can see it being loaded. It looks like this:
<link rel="alternate" type="application/rss+xml" title="Siege the Artist ยป Feed" href="http://localhost:8888/feed/" /> <link rel="alternate" type="application/rss+xml" title="Siege the Artist ยป Comments Feed" href="http://localhost:8888/comments/feed/" /> <link rel='stylesheet' id='admin-bar-css' href='http://localhost:8888/wp-includes/css/admin-bar.css?ver=20110622' type='text/css' media='all' /> <script type='text/javascript' src='http://localhost:8888/wp-includes/js/l10n.js?ver=20101110'></script> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js?ver=3.2'></script> <script type='text/javascript' src='http://localhost:8888/wp-content/themes/siegetheartist/js/gallery.js?ver=3.2'></script>What am I doing wrong to not let jquery work properly???
Forum: Fixing WordPress
In reply to: How do I display a specific function on a specific pageI found the codex on the wordpress site for the function to call a page. Its is_page() just like I had originally thought. The above code works like a charm.
Forum: Themes and Templates
In reply to: How do I load different style sheets to different pages?Yup. That did it. And I learned something. ๐ I didn’t know that you can open and close the php at will without effecting how it works. Thank you so much for your help. I appreciate it.
Forum: Themes and Templates
In reply to: How do I load different style sheets to different pages?The following is not working:
<?php
if ( is_page_template( ‘home.php’ ) ) {
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>”>} elseif ( is_page_template( ‘contact.php’ ) ) {
<link rel=”stylesheet” href=”<?php bloginfo(‘template_directory’); ?>/css/contact_form.css” media=”screen” type=”text/css” />} else {
}
?>
I’m pretty sure its because since I have opened the php and trying to write html inside of it without it being a string, it is getting confused when I try to re-open php inside of the file path. So I “think” I know what the problem is, but I don’t know how to solve it. ๐ I thought of making it a string by putting it inside of quotes but it did nothing. Any suggestions?
Forum: Themes and Templates
In reply to: How do I load different style sheets to different pages?Would you please give me an example of what it would look like when “Load CSS here” is replaced with an actual path? Also, if I have more than 2 templates that I want style sheets to load on, would I just continue adding more “elseif” statements? Like this: ?
<?php if ( is_page_template( 'thispage.php' ) ) { Load CSS here } elseif ( is_page_template( 'this_other_page_1.php' ) ) { Load CSS here } elseif ( is_page_template( 'this_other_page_2.php' ) ) { Load CSS here } elseif ( is_page_template( 'this_other_page_3.php' ) ) { Load CSS here } else { Load CSS here } ?>