Fatal error
-
Im trying to add “featured images” to my posts, (and pages), so that they appear in my featured slide. But when i upload the images, i get this message
“Fatal error: Call to undefined function get_post_thumbnail_id() in /home/suziegibb/domains/suziegibb.com/public_html/wp-admin/includes/media.php on line 1292”
What does it mean, and how can i fix it please?
for reference, my website is – https://www.suziegibb.com
-
Bump – kind of important
Mark-
You need to do two things in your theme files in order to use thumbs/featured images:1. functions.php
// Add post-thumbnail capability add_theme_support('post-thumbnails');
This is necessary to allow post thumbs (featured images) to be used.
2. Wherever you want the post thumb/featured image to appear:
here, in index.php<?php the_post_thumbnail(); ?>
As, for example:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_post_thumbnail(); ?> <?php the_content(('(...Read on!...)')); ?>
(etc…..)
Hope that is a help to you. –Bill
Thankyou!! i dont really understand number 2, but il get there ?? thank you so much bill!!
Bill – do i copy and paste number 1, into functions php?
Mark-
re #2: you place the line of php code-
<?php the_post_thumbnail(); ?>
-in the place where you want the thumb to appear.In the example from an index.php file, if you look at your own index.php file, you will see “The Loop” (starting with: if (have_posts()….). In the example I gave, the_post_thumbnail() is placed before the_content(). So when you display the index page, you will see the thumbnail, and then below it the content (the text) of the post.
If we’d reversed things, such as:
<?php the_content(); ?>
<?php the_post_thumbnail(); ?>– you would now see the post content appearing first, and after/below it you would see the post thumbnail.
BTW, all of this assumes that you have added an image to a post via the Featured Image link at the bottom right of the Post page.
If you are using a slideshow function, I don’t believe that featured image/thumb is the way to go. You should probably look at the documentation for the slideshow function, which will likely tell you where to upload the images to be used in the slideshow.
–BillHey bill – first off, i know it says “mark” but thats my (supposed to be) web manager. My names Suzie, im on his account. Im new to code, so i really have trouble understanding what is put forward to me sometimes (sorry).
And yes, i used the “featured image” link, in the bottom right hand of the post page. Il look to see, how to get it into my slideshow later, but for now, i just want an image to replace the “camara icons” in my posts. I have 6 tester posts, and I am hoping to have the images set, to all the posts, by the end of the night. As, what i have at the moment, are just 6 grey images, of camaras lol.
I really hate to be a pain, but can you tell me wether i add that to my stylesheet? or do i add that code somewere else?
thankyou!
Suzie- (I got “follow the post” email on your two replies)
OK, 2 things, based on your replies:
———-Making the change to functions.php
1. Locate the file, which is in wp-content > themes > (your theme folder) > functions.php
2. Edit this file in a simple text editor (Notepad++, other good editors, even Notepad itself)
3. The simplest place to put your code is at the top of the file, just below the very first opening php line of code:
<?php (then you put your code here next:) // Add post-thumbnail capability add_theme_support('post-thumbnails');
4. Then Save (well, yeah!), and you’re done.
———-On why you are getting your default camera image:
I can’t see all the code (such as the php), but when I viewed the Source code being sent to the browser, this is what your html
image tag looked like:
<img src="https://www.suziegibb.com/wp-content/themes/Spexel/thumb.php?src=https://www.suziegibb.com/wp- content/themes/Spexel/images/default.jpg&h=251&w=592&zc=1" alt="test 5"/>
I would say that something is tangled up here, in the filename. You can see that there is a path to your default camera image- in
fact, I was able to put
https://www.suziegibb.com/wp-content/themes/Spexel/images/default.jpg
into Firefox, and bring up the default camera image.On the other hand, I don’t see a successful path for your desired image- you see how you have thumb, followed by php?- I don’t think there is actually an image being pointed to.
So I would suggest trying a very simple img tag, just try to point to an image without a lot of fancy stuff. This is to satisfy yourself that your current img code is probably incorrect.
———-
Good luck! –BillReally sorry about this bill, can you tell me as simply as you can? I did the first solution, by adding the code to the function.php. That is now sorted, but i dont really understand the 2nd solution, what i want is images in the posts, ive set the featured images, and they appear in the posts themselves, but they do not show the image, on the homepage, were my 6 test posts are.
Take this site for example –
this site has pictures on the posts, rather then the gray camera, thats what ild like,
sorry to be a pain.
SuzieSuzie-
I took a look at your site suziegibb.com, and at least one thing is this: for test-1, you have path to Suziereal.png, while for test-3 (as an example), your path is to your default camera image default.jpg
The img tag information:
Image 1 https://www.suziegibb.com/wp-content/themes/Spexel/thumb.php?src=https://www.suziegibb.com/wp-content/uploads/Suziereal.png&h=140&w=180&zc=1 image 3 https://www.suziegibb.com/wp-content/themes/Spexel/thumb.php?src=https://www.suziegibb.com/wp-content/themes/Spexel/images/default.jpg&h=140&w=180&zc=1
Do you see what I mean? You are getting the default image because that is what you are pointing to in test-3.
——Re inserting the <?php the_post_thumbnail(); ?> code in your files:
a. With a text editor (Notepad++, Notepad, etc), open the files where you want the code to go. This is probably index.php and single.php.
b. Find the place where you want the image to appear (for example, just above the code that says the_content(), and insert the_post_thumbnail() code there.
c. Save the file.
——-In the end, you may just need to sit down with someone who can review your files and all the code and see exactly what is going on. –Bill
- The topic ‘Fatal error’ is closed to new replies.