• I am trying to show the author of posts from my wordpress site in my chartbeat reports and they are saying to show them I need to use dynamically using CMS variables or DOM API methods

    I have tried this: document.getElementsByClassName(‘author’);

    But that shows [Object Htmlcollections] as the author then. What am I missing?

    Thanks for any help.

    • This topic was modified 4 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The .getElementsByClassName() method returns an array-like object of found elements, even if only one is found. Access the individual elements by their zero-based index number. document.getElementsByClassName('author')[0] returns the first element found. If you get another object, try applying an index to that as well. If getting elements by index no longer works, you’re down to the individual node. Look up what object properties the node has. .innerHTML is common and represents the HTML content within the node.

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to show author of post in chartbeat’ is closed to new replies.