Articles of attribute

Remove image classes from post thumbnail output

I wish to remove the image classes generated by default in the output whenever post_thumbnail() is called – <img width=”1024″ height=”768″ src=”×768.jpg” class=”attachment-large wp-post-image” alt=”Yet another example”> I’ve read a bit about the remove_action() filter and this seems the way to go but I’m not sure how to use it.

Add attribute to shortcode dynamically

I’m looking to add an attribute to a shortcode used in a post dynamically. For example, say we start with: [shortcode-name] I’d like to add the “attribute=xxx” portion to the shortcode so it is effectively like so: [shortcode-name attribute=xxx] For just the first shortcode encountered in a post. Is this possible? Thanks!

How to add a rel attribute to images that contains their categories?

I’ve added categories to images, so that I can use them to filter images within a portfolio page. Now I’m thinking I need to add the rel attribute to each image that contains its assigned categories. Is this the right approach? If so, how do I add add rel with the applicable categories?

How to retrieve alt attribute for an attachment (uploaded image)?

I have some IDs of attachments (images, not from current post). How to I get the alt attribute for those images? I have tried to look into wp_get_attachment_image_src and wp_get_attachment_metadata but couldn’t find the alt attribute stored in neither of those this is where I’m looking for the alt: while(the_repeater_field(‘featured_pics’)): //this is an array of […]

Removing width and height attributes from wp-get-attachment

I’m using this to remove the height and width attributes of images. Everything works fine except that it messes up the masonry container because of the images have no height. How could I apply this filter only to a determined div id/class?

Remove 'rel' attributes from the_category() output

I am trying to get the categories associated with a post in it’s meta section by using the following code: <div>FILED AS: <span class=”gf-post-meta-result”><?php the_category(‘ &bull; ‘) ?></span></div> WordPress is generating the markup as: <div>FILED AS: <span class=”gf-post-meta-result”> <a href=”http://localhost/test/category/uncategorized/” title=”View all posts in Uncategorized” rel=”category tag”>Uncategorized</a> </span></div> This part rel=”category tag” is making my […]

Shortcode displays only default attribute values

For some reasons every shortcode, that I try to add to functions.php, displays only default attribute value and ignores what I specify in a post. E.g.: function my_shortcode( $atts ) { extract( shortcode_atts( array( ‘id’ => ’18’, ), $atts ) ); return $id; } add_shortcode( ‘sc’, ‘my_shortcode’ ); So I use shortcode [sc id=”81″] and […]

Get multiple shortcode attribute values

I’m trying to get several values from a shortcode. I tried several things without success. The shortcode looks like this: [myshortcode metakey=”<field_key:key1, title:Title 1><field_key:key2, title:Title 2><field_key:key3, title:Title 3> ] How would I get the field_key values? So in this case key1, key2 and key3?

wpautop() when shortcode attributes are on new lines break args array

I have a custom shortcode tag with a few attributes, and I would like to be able to display its attributes on new lines – to make it more readable to content editors: [component attr1 =”value1″ attr2 =”value of the second one” attr3 =”another” attr4 =”value” … attrN =”valueN”] The reason behind this requirement is […]

Sort post by attributes 'order'

How to sort the displayed posts by attribute “order“? In functions.php I added the “Attributes” for posts function wpzen_add_attributes_to_post() { add_post_type_support(‘post’, ‘page-attributes’); } add_action(‘init’, ‘wpzen_add_attributes_to_post’); function wpzen_change_post_order($query) { if($query->is_main_query()) { $query->set(‘orderby’, ‘menu_order’); } } add_action(‘pre_get_posts’, ‘wpzen_change_post_order’); The code displays an overview of posts looks like this: <?php $show_posts = ’12’; $cat_name = ‘Products’; $paged = […]