1

I am in a category.php, and I have to write the category name outside of the Loop. The category name needs to be pulled dynamically through PHP.

<p>You are browsing <?php get_the_category  ?> articles.</p>

I tried the above one, but it didn't work. Whats the fix?

2 Answers 2

3

You're looking for single_cat_title().

2
  • what it is it equivalent for a tag: single_cat_title();?
    – WordCent
    Commented Oct 2, 2017 at 12:33
  • 1
    WP functions are generally quite consistently named, so for tags you'd want single_tag_title(). For generic terms you'd be looking for single_term_title().
    – Chris Cox
    Commented Oct 2, 2017 at 12:36
-1

I have to admit that I am not fully understanding your question. Would you want to write a plugin with a widget to accomplish your task? *What are you trying to do?

Usually I find that if I need to loop outside the loop, that I have to define which categories apply and which do not, usually for me another loop that is outside the Wordpress default loop. I am working with an example of article loops and I hope to update this answer before it is fully complete.

For those voting - please wait until I have a complete answer available before voting. I hope to take the updates to the question and update the answer accordingly.

Thank you for asking your question.

8
  • sir, please read the question it has all the requisite details. A simple one in deed.
    – WordCent
    Commented Oct 2, 2017 at 10:07
  • slightly updated the questions.
    – WordCent
    Commented Oct 2, 2017 at 10:13
  • I am using a custom-field and I need to similarly cycle among those on the particular wordpress page where the widget is located (using also the [widgets_on_pages] plugin to place my widget nicely centered on the page. My current example is at: shalomisrael.org/news/new-york-business-review I need to loop through the defined custom fields on each page. Perhaps this is similar to what the question author is asking, so I appreciate additional detail. Commented Oct 2, 2017 at 10:13
  • It looks like you are spamming and trying to make backlinks. Please avoid spamming.
    – WordCent
    Commented Oct 2, 2017 at 10:15
  • Could you provide a link to your full source so I can understand it? I am not trying to back list links as I am working on this right now, and the question seems similar. If you post a link on your web-hosting that would be appreciated, or even here! Commented Oct 2, 2017 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.