Articles of template tags

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 the class only. How to do this? I am trying this:- class modifyUserMeta { function modifyUserMeta(){ add_filter(‘get_user_meta’,$this->modifyMeta); } function […]

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 the_comments() tags. I’ve looked into my category_template.php file but am having trouble identifying what exactly I need to tweak to get […]

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 custom field named “country_flag”. I want this custom field to store for every post a link to a […]

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 (themeslug_posted_on) to show them as well? My pre get posts filter: add_filter( ‘pre_get_posts’, ‘get_my_cpt’ ); function get_my_cpt( $query ) { […]

How do I str_replace with template tag?

I have a template tag of: <?php echo the_post_thumbnail( ‘full’ ); ?> It outputs: <img src=”/graphics/magazine/802/1.jpg” class=” wp-post-image” alt=”” /> I want to remove ‘class=” wp-post-image” ‘ from it. My understanding of str_replace is little, and I’ve tried various ‘guesses’ but not successfully.

Template Tag Does Not Work in Page Template

I’ve created a page template and used this code to call a post which contains a shortcode: $post_id = 129; if( get_post_status( $post_id ) == ‘publish’ ) { the_content(); } The problem is that this code works fine in the index.php but not in my page template. Why is that? Help please.

How to query details of images in gallery that is attached to a post

I have several images attached to each post. I need to generate a gallery, but because it’s heavily customized I don’t want to use a gallery plugin, nor the gallery short code. It’s also situated in a DIV that is totally separated from the post content/title etc. so it has to be stand-alone code in […]

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->the_post(); style I’m accustomed to and have built a lot of shortcodes and loop styles around. How can I change the code below into […]

is_front_page and is_home are not working in page.php

I’m trying to target my landing page with is_front_page or is_home in my page.php file but it’s not working. I have set the settings > reading to a static page. However, if I create a page-home.php everything works fine (without the tags of course). But, if I use the is_front_page or is_home on the index […]

What is the p parameter in a get_posts() parameter array?

I’ve seen code that looks like this: get_posts(array(‘p’ => $thumbnail_id, ‘post_type’ => ‘attachment’)); What is the definition of the p parameter and is it documented anywhere? I can’t find anything about it on the Codex page for get_posts().