Questions tagged [template-tags]

Template tags are custom WordPress-specific functions for use in theme template files.

Filter by
Sorted by
Tagged with
1
vote
2answers
1k views

Minor css-change based on topmenu - how?

I want to make minor css-changes based on the choice of the top (root) menu. What's the proper way to handle this in WP? //edit// It's a website (pages), no blog, and basically, the colors of some ...
18
votes
2answers
16k views

Manually set global $post vars with an ID, in order to use template tags

I have a function retrieving ID's of posts by very specific means. I need to be able to set the global $post in order to use functions like the_content(), which does not allow an ID as a parameter. ...
10
votes
3answers
14k views

Echo author ID in author.php

This is probably a super simple question. But how do I echo the ID of a user on author.php? I've tried the_author_meta('ID') But it didn't seem to want to work. I want to echo it at the end of a ...
1
vote
3answers
86 views

different tag different stylesheet

i have tags, and for some tags i want to load a different stylesheet But i don't know how i have.... function customstyles() { if ( is_tag( 'circulair' ) ) { //Register and enqueue the ...
5
votes
1answer
2k views

get_parent_theme_file_path vs. get_template_directory

I've been reading about the new functions for referencing theme location added in v4.7. I read through the trac ticket. I understand why they created these functions and the benefit of ...
5
votes
2answers
3k views

How to get the clean permalink in a draft?

When I use the_permalink or get_the_permalink in a draft or scheduled post, the URL provided is not the "final" permalink—it is the unpretty ?p=xxxxx version. How can I get the final, "clean" ...
4
votes
2answers
3k views

Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation

I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since ...
2
votes
1answer
5k views

Wordpress function/template tag to get first n words of the content

OK, this might be a duplicate, I was just unable to put my idea in proper search terms, sorry for that! Is there a built-in function or template tag to get the first n words of the content? I mean ...
0
votes
2answers
2k views

How to change a custom query into a standard loop?

I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query while ( $the_query->have_posts() ) : $the_query-&...