Tag Info

New answers tagged

0

Thanks Pieter and realloc. I came up with this solution: Added meta_key=important&meta_value=1 in wp_list_pages. And gonna use custom field for pages "important: 1". This is for list of IMPORTANT child pages. function important_list_child_pages() { global $post; if ( is_page() && $post->post_parent ) $childpages = wp_list_pages( ...


0

The function wp_list_pages() has a filter that can come in handy here: /** * Filter the array of pages to exclude from the pages list. * * @since 2.1.0 * * @param array $exclude_array An array of page IDs to exclude. */ $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); Personally I would rethink your ...


0

You'll have to drop all page related functions if you need this type of functionality. Pages was never meant to have taxonomies, and therefor none of the page related functions was build to offer any kind of support for taxonomies Rethink your structures and look into the use of custom post types and custom taxonomies. You can also look into using custom ...


0

There was a stray flush_rewrite_rules() in my functions.php, commenting it out made everything work properly. From there I just had to include the custom post type's posts in the archives page, a la http://css-tricks.com/snippets/wordpress/make-archives-php-include-custom-post-types/


0

Your second attempt is close, but you need to echo the result of the function and you may want to provide it with some arguments. The below should output the list of tags space-separated: <meta name="post-tags-here" content="<?php echo get_the_tag_list( '', ' ', '' ); ?>" >


1

Use get_the_tags() instead of the_tags(), get_the_tags() does the following for you: Returns an array of objects, one object for each tag assigned to the post. with which you can work with to achieve what you want. See the examples on the codex page for more information.


1

Try give a name for your rewrite, like so: 'rewrite' => array( 'slug' => 'news-updates-archive', 'with_front' => true, 'feeds' => false, 'pages' => true, ) So you will avoid any problem. Also, the last functions you're using are unnecessary. You can setup it on register_post_type: 'taxonomies' => ...


1

The currently logged in user The \WP_User object/instance can be retrieved via: $user = get_current_user(); There's a shortcut API wrapper to fetch the ID: $user_id = get_current_user_id(); $wpdb and the WP "DBAL" WP basically uses $wpdb as DBAL/Database Abstraction Layer. It got plenty of public methods and some higher level wrappers for convenient ...


0

The main changes needed in order to use tags instead of categories would be: In section one, change... $args['category__in'] = $categories; to $args['tag__in'] = $categories; And in the second section, change the cats loop: $title = esc_attr($instance['title']); $number_posts = (int) $instance['number_posts']; $categories = (array) ...


0

In your regex there is a space before the # $mh_regex = "/\ #[a-zA-Z0-9-]+/"; so it would match # tag instead of #tag. It might be a good idea to test your regex using this online tool: http://www.regexr.com/ it's really usefull for testing


1

You can use categories with pages by registering the category taxonomy for the page object type: function categories_for_pages(){ register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'categories_for_pages' ); If you want to use a separate taxonomy for this, you can register your own taxonomy for pages.


1

One way to do it is to store the order of the tags as post meta data, using the action set_object_terms which happens to pass the tags in the order they appear on edit, eg in your "functions.php": // Called in admin on updating terms - update our order meta. add_action( 'set_object_terms', function ( $object_id, $terms, $tt_ids, $taxonomy, $append, ...


7

I'd say the easiest way to do it is use the get_terms_args filter and unset the number limit if the context is right (the AJAX request to get the tag cloud): function wpse_64058_all_tags ( $args ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagcloud' ) unset( ...


4

You should use pre_get_posts to alter the main query on the home page. With the proper conditional tags and parameters (check WP_Query for available parameters) you can achieve what you need You can do the following to just display posts from a given tag on your homepage add_action( 'pre_get_posts', function ( $query ) { if ( !is_admin() && ...


0

For that; first you have to make Custom Page template and add following loop in it and customize it in what ever way you want. <?php $args=array( 'tag' => 'yourtag', 'showposts'=>5 // set number of post you want to display ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ...


0

A simple way to do is to edit your theme's "search.php" (copying it from the parent theme into your child theme's directory first if you're using a child theme) and then before the posts loop putting something like: <?php if ( $tag = get_term_by( 'name', get_search_query(), 'post_tag' ) ) { ?> ...


0

As @Robert hue says you can't do it directly, you need a filter and a CASE in the orderby eg $args1 = array ( 'orderby' => 'tag_count', 'order' => 'DESC', 'post_type' => 'post', 'pagination' => true, 'posts_per_page' => '1', // 1 post per page?! 'meta_key' => '_thumbnail_id', ...



Top 50 recent answers are included