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

learn more… | top users | synonyms

3
votes
3answers
2k views

Remove line breaks in wp_list_categories()?

I am trying to output a list of categories per an article. I am using the following code, <?php wp_list_categories('child_of=270&style=none'); ?> (string) Style to display the categories ...
0
votes
4answers
349 views

Function to echo (or display?) wordpress tags in the head section

I can't figure this out but I'm trying to echo the post Tags of the post in the <head> section. This code resides in the <head> section of the site. Basically I want the post tags to ...
0
votes
0answers
20 views

edit_post_link returns blank

I'm using edit_post_link in The Loop and the function keeps returning the $before and $after arguments with blank content. <?php edit_post_link('edit', '<p>', '</p>'); ?> returns ...
5
votes
1answer
4k 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 ...
0
votes
0answers
19 views

Hide Certain Tags on Single Post Page

I'm trying to hide certain tags from single posts pages. I've googled and found 2 codes but both are hiding the whole post page. I'm using a theme that needs using 2 tags ticker and slider to show ...
0
votes
1answer
62 views

How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]

I have a shortcode, widget and template tag that need to load CSS. I am registering in init, and enqueueing as required. The only problem is, it is adding the CSS loader at the bottom of the page, ...
0
votes
1answer
179 views

Calling the first & last post by category in custom post type

I have custom post type for comics, called “comic” and have written a basic comic navigation. First —previous — (current) title — next — and last comic. In functions.php, this code calls for the ...
0
votes
4answers
3k views

Multisite get_home_url(); - Getting URL for current site

What would be the replacement for get_home_url() when using a multisite? For example, if I have one theme installed across several sites, and within the theme there are links that need to be specific ...
0
votes
0answers
57 views

'Post_tag' taxonomy tags don't link to existing posts in CMS

I'm using this bit of code to retrieve the object data for post_tag taxonomy. <?php $tax = 'post_tag'; $tax_terms = get_terms($tax); if ($tax_terms) { foreach ($tax_terms as ...
0
votes
0answers
39 views

Get list of body classes for X page?

Is there a way to grab the list of body classes for X page? I tried: <?php get_body_class('home'); ?> but got a console error for function not defined.
4
votes
2answers
5k views

why doesn't the_content() work in this {single-custom_post_type.php} page?

This code is from my page single-publication.php. It outputs the relevant custom fields etc (here wrapped in template tags), but the_content() won't output the post content. I've resorted to using ...
0
votes
1answer
212 views

Getting custom post type author and date published

In underscores I can get my custom post type just fine with pre get posts along regular blog posts. However the date published and author does not display. How can I modify my template tag ...
1
vote
1answer
52 views

Is there a way to display a menu using the ol tag instead of the default ul tag?

I'm trying to display a menu using wp_nav_menu(). The default markup that the function generates is a menu parented by a <ul> tag like so: <ul> <li><a>Menu ...
0
votes
2answers
2k views

Displaying list of subcategories and not parent category

I have a blog which has three top level categories. Each top level category has a list of sub categories. I am displaying only certain top level category posts in certain sections of the website. ...
0
votes
1answer
33 views

Custom Fields Question

I'm new to wordpress and I am trying to understand these custom fields. I read the wordpress codex page refering to custom fields but I have some questions. I take for example my site. I created a ...
0
votes
1answer
218 views

the_category() tag not styling HTML or CSS

I am having problems getting my the_category() template tag to style accordingly with the rest of my theme. I believe this is because the HTML isn't output the same way as the the_author() and ...
0
votes
2answers
42 views

comments_number fails to print

I want to display the number of comments on a post using the template tag <?php comments_number( $zero, $one, $more ); ?> However, for some reason this tag does nothing and it is ...
0
votes
0answers
63 views

How do I get is_single() to return true when called internally from the_content()?

I have a custom page, e.g. blog.php?post=42 that shows a GET-specified post like so: <?php require('wordpress/wp-blog-header.php'); ?> <!-- my non-wordpress site's html goes here --> ...
0
votes
1answer
5k views

Get permalink and title by post name?

In the theme there is a custom post type called faq I just want to get certain post by its name (NOT by id cause no id exist). <?php query_posts('post_type=faq') ?> how to get the_tile() and ...
0
votes
1answer
29 views

How to modify template tags function

By default, get_user_meta returns an array, a single value or false. I want to change the return value somehow. How to do that? I want to modify the return type of a template tag get_user_meta inside ...
1
vote
2answers
269 views

How to check if I am inside the WP Theme Customizer preview?

I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ? For example: <img ...
0
votes
0answers
36 views

How to add links under every posts? ( WHILE BUILDING PLUGIN not manually )

I want to use, change, add and delete the links that appears with every posts. (e.g. May 21, 2014| 1 Comment) If I'm not wrong these are called template tags. I can play with them manually by getting ...
1
vote
1answer
418 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
0answers
63 views

Own Custom Tags/Category page ( posts)

I want to make a page where on each tags : My page should look alike : http://www.missmalini.com/aamir-khan-2/ Above page is coming from http://www.missmalini.com/celebrity-fan-pages/ this are ...
-2
votes
1answer
763 views

Adding more information to a Content Product Category

The template content_product_cat is responsible for showing the product categories images and its name. I want to display more information below the name of a category e.g a Category called 'Books', I ...
0
votes
2answers
278 views

Template tags vs get_template_part() vs functions.php

When to use template tags and when to use get_template_part() and when to use function.php? I am confused at them. For example, if I want to show related portfolios under single portfolio, I can ...
0
votes
3answers
957 views

How to support letting users add their OWN logo to a custom theme?

I am a rookie theme developer (3 months in) and I am trying to figure out how to implement the following functionality: The theme I am building has a logo which I would like for users to be able to ...
0
votes
0answers
40 views

Tags results not displaying for post types

UPDATE Here is the thing... I have a structure where I created a post type which has taxonomies and also tags. Let's call it Works. However, when I need to filter by tags, using the tag template, ...
4
votes
2answers
3k 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. ...
0
votes
2answers
186 views

Organize template parts and page templates in folders in regards of template hierarchy

Hello and happy new year Suppose one has a large theme composed of several post types, page templates and a bunch of custom loops and template parts which is best keeping in separate php files. ...
3
votes
4answers
726 views

How to show the real post date in a draft

When looking at a draft post, get_the_date() only seems to return today's date, not the post date, even if I have selected another date on the post edit screen. Is there a way to show the "actual" ...
0
votes
1answer
194 views

WP Query conflict on tag.php and category.php template

My WP_query in the header menu fails to pull any posts on tag and category pages only. Error occurs even with the Loop removed from those template pages. The menu in the header lists the parents. ...
-1
votes
2answers
121 views

Why don't some template tags work when querying information on single.php?

I'm trying to fetch content about the current post into the header.php of my theme (to dynamically insert Facebook OpenGraph Metadata). Since I'm on a single post page, shouldn't it be able to run ...
0
votes
1answer
130 views

navigation link based on custom field

I'm looking for a method to order posts by a custom field so that the navigational links on a single post template would point to the next or previous post in the sequence defined by a number in a ...
3
votes
2answers
1k 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" ...
1
vote
1answer
656 views

Multiple templates for single custom post type

Does anybody know of a way to modify the wordpress template process so that a single custom post type can be displayed on two separate templates based on the value of a custom field. For example I ...
0
votes
1answer
2k views

Setting selected term_id with wp_dropdown_categories?

I'm using this code to get the term_id of a custom taxonomy. The drop down does list the terms of the taxonomy Type. When I print the $terms variable I see the term ID of the post i'm editing on the ...
1
vote
2answers
2k views

Getting tagid from tagname

Currently I am working on a rating plugin. You can see the code I got so far below: <?php if (function_exists('get_highest_rated')): ?> <ul> <?php get_highest_rated_tag(12, 'both', 0, ...
1
vote
5answers
5k views

On the category page, get the category object

Right, hopefully a nice and simple one... I'm on a category page with the id of 4, I want to get the category object back so I can interogate a few values. I've had a good old look in the WP codex ...
0
votes
2answers
854 views

add short code not working

I am new to wordpress, I am creating a plugin and for the short code, I am using the short code api. But when I insert this shortcode in my page, it displayes as it is, it does not display the ...
0
votes
1answer
36 views

Tags Sorted By Characters?

If i put multiple tags in a post then after publishing the post all tags are auto arranged by Character Serial, like A B C D... any idea if i wish to have all tags will not sorted or arranged by ...
0
votes
1answer
171 views

How can I include custom category and tag base in template files?

How can I include custom category and tag base names in the category and tag template files? Specifically, I'd like to include in the page title of category and tag pages the custom category and tag ...
2
votes
1answer
87 views

Strange Behaviour with is_home()

I'm having an odd issue, although I can understand why it works like this I do need to find a way around it. I have used the the request filter to modify the query for the home/index page to select ...
1
vote
0answers
49 views

Checking if a specific date archive is being displayed

The is_month(), is_year() or is_week functions don't accept arguments. Are there any other functions available that I'm able to use to determine if I'm viewing specific month/year/week archive ? Or do ...
1
vote
2answers
179 views

How can I link a CSS file only on single posts?

If I understand is_single() correctly, it's only supposed to return true when the current "post" (in a generic sense) is a literal post (i.e., it has a post_type of post), and that it will return ...
0
votes
1answer
900 views

how to limit and display tag?

Hi i need to show random 3 tags for a post. all my posts have been tagged with more than 10 tags, i need to display any 3 tags randomly. for eg: A sample post <a href="/tag1">Tag1</a> ...
1
vote
1answer
1k views

Check if password protected post is visible

Is there anyway of checking if a password protected post is visible / not visible? I want some thing that says this; If the post is password protected (that parts fine) and the correct password ...
0
votes
1answer
53 views

Targeting all pages except top level pages

I have used '0' == $post->post_parent successfully in my templates to target top level pages. However, I cannot seem to target all pages EXCEPT top level pages: <?php if ( '0' !== ...
6
votes
1answer
2k views

How do I display a tag cloud under my post that only shows tags from that post?

I've be looking to add a tag cloud under my post that only shows tags pertaining to the post. The tags shown should be in a tag cloud format; the post tags that have more post tagged with it will be ...
3
votes
1answer
65 views

When to use which plugin output method?

I'm a Drupal dev, getting into Wordpress. So far as I can tell there are a few different methods by which a plugin can output content on to a Wordpress site: Shortcode Rewrite API Widget API ...