Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


PHP/Wordpress help needed with meta data in header.php
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

PHP/Wordpress help needed with meta data in header.php

GM2015GM2015 Member
edited September 2015 in Help

I'm having problems with php5.6 and wordpress 4.3. I want to have my facebook and twitter descriptions to be automated via php.

THe issue is twitter:image and facebook og:image is broken when php the post thumbnail is invoked. I manually choose a thumbnail that's most relevant to an article.

Here's the relevant header code:
http://pastebin.com/CQv0rB0X

Relevant part's output code with my note there marked from firefox's source inspection:
http://pastebin.com/adTjih9j

The thumbnail function is enabled in the wp theme function.php file and thumbnails work nicely on related posts and category and tag pages.

But I just can't get this working.

Twitter validator don't work so facebook scraper won't work either.

Thank you!

I should have added I used https://codex.wordpress.org/Function_Reference/the_post_thumbnail and neither of these worked.

Should op go sleeping instead?
  1. Go Home6 votes
    1. I'm tired too
      33.33%
    2. Lowendtalk.com is a place where serious businesses conduct deals and is not for asking questions.
      66.67%

Comments

  • the_post_thumbnail() is meant to be used for generating HTML IMG tags, in other words it's an all-inclusive function to get and render the image when viewed in a browser.

    You probably just want the image source (URL path to the file). You should look at the source code for get_the_post_thumbnail() and then based on that use wp_get_attachment_image_src() to get just the URL.

    Thanked by 2GM2015 ihatetonyy
  • If that works, I'll marry a pretty neighbour of yours!

    JustAMacUser said: the_post_thumbnail() is meant to be used for generating HTML IMG tags, in other words it's an all-inclusive function to get and render the image when viewed in a browser.

    You probably just want the image source (URL path to the file). You should look at the source code for get_the_post_thumbnail() and then based on that use wp_get_attachment_image_src() to get just the URL.

  • My initial guess...this function the_post_thumbnail work Inside the loop

Sign In or Register to comment.