joshM-4
Support threads created in the last 30 days: 0
Favorite Forum Topics
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Date fields from Events Manager are not interpreted as dates.
Started by: tammot
in: Toolset Professional Support
Problem: Solution: You can find proposed solution, in this case, with the following reply: Relevant Documentation: |
2 | 13 | 6 years, 1 month ago | ||
Changing permalink for custom post types so they don't use post name »?">how get the id of the previous post for Changing permalink for custom post types so they don't use post name »?
Started by: Mario
in: Toolset Professional Support
Problem: function shortcode_next_post_id ($atts) { global $post; $next_post = get_next_post(); if (empty ($next_post)) return 0; return $next_post->ID; } add_shortcode('next-post-id', 'shortcode_next_post_id'); Solution: <a href="[wpv-post-url id=[next-post-id]]"> [types field='rs-brandname' id='[next-post-id]'][/types]</a> Please make sure you have already registered the custom shortcode name in the Toolset setting page: Relevant Documentation: |
2 | 4 | 6 years, 12 months ago | ||
Previous and Next Post Navigation when sorted by menu order
Started by: Shreyas Khatri
in: Toolset Professional Support
Problem: < Previous : Post Name | Post Name : Next > Solution: 1. For this you should create custom shortcodes. Please add this code in your theme’s or child theme’s functions.php file: add_shortcode( 'next_post', 'next_shortcode' ); function next_shortcode($atts) { global $post; ob_start(); next_post_link( '<span class="nav-next">%link : Next ></span>', '%title' ); $result = ob_get_contents(); ob_end_clean(); return $result; } add_shortcode( 'prev_post', 'prev_shortcode' ); function prev_shortcode($atts) { global $post; ob_start(); previous_post_link( '<span class="nav-previous">< Previous : %link</span>', '%title' ); $result = ob_get_contents(); ob_end_clean(); return $result; } // Customize Post Link Order function my_custom_adjacent_post_where($sql) { if ( !is_main_query() || !is_singular() || 'playground' != get_post_type() ) return $sql; $the_post = get_post( get_the_ID() ); $patterns = array(); $patterns[] = '/post_date/'; $patterns[] = '/\'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\'/'; $replacements = array(); $replacements[] = 'menu_order'; $replacements[] = $the_post->menu_order; return preg_replace( $patterns, $replacements, $sql ); } add_filter( 'get_next_post_where', 'my_custom_adjacent_post_where' ); add_filter( 'get_previous_post_where', 'my_custom_adjacent_post_where' ); function my_custom_adjacent_post_sort($sql) { if ( !is_main_query() || !is_singular() || 'playground' != get_post_type() ) return $sql; $pattern = '/post_date/'; $replacement = 'menu_order'; return preg_replace( $pattern, $replacement, $sql ); } add_filter( 'get_next_post_sort', 'my_custom_adjacent_post_sort' ); add_filter( 'get_previous_post_sort', 'my_custom_adjacent_post_sort' ); ==> Whereas ‘playground’ is your custom post type slug, that you need to replace in the above code. 2. Then, add this shortcode in your Content Template to display Previous and Next post links: [prev_post] | [next_post] |
3 | 10 | 7 years, 3 months ago | ||
Show most popular posts based on post view count
1
2
Started by: Nicholas
in: Toolset Professional Support
Problem: I would like to use the post view count generated from a 3rd party plugin (dfactory's Post Views Counter) to sort a View by post popularity. I would like to use this for the Product post type created by WooCommerce. Solution: 1. Create a new custom field group for products. Add a custom number field called "Product View Count". Make this field required, with Number validation, and make the default value 0. (see attached field.png in the post below) add_action( 'pvc_after_count_visit', 'update_toolset_view_count' ); function update_toolset_view_count ( $post_id ) { $post_type = 'product'; // only update the post view count for products if ($post_type == get_post_type($post_id)) { $view_count = get_post_meta($post_id, 'wpcf-product-view-count', true); $view_count = $view_count ? $view_count : 0; // update and increment the view count for this product update_post_meta($post_id, 'wpcf-product-view-count', (intval($view_count) + 1)); } } 5. Navigate to one of your products in wp-admin. You should see your custom field here with a value of "0" by default. If you are okay with starting from 0, you don't need to change this value. If you want to start calculating from the view count as it exists already, you must copy + paste that value from the front-end of your site. Relevant Documentation: |
2 | 17 | 7 years, 4 months ago | ||
How to show next / previous child post?
Started by: Amin
in: Toolset Professional Support
Problem: I have a parent post type "Parent" with child post type "Child". Each child belongs to a single parent, and parents can have multiple children. On a single child page, I want to link to the next and previous children (sibling posts in order by post date) of the same parent using "NEXT" and "PREV" links. How can I accomplish this? Solution: Use some custom shortcodes to create your Next and Previous buttons. // replace "parent" and "child" with your post type slugs add_shortcode('wpv-child-prev', 'wpv_child_prev'); add_shortcode('wpv-child-next', 'wpv_child_next'); function wpv_child_prev() { return wpv_child(-1, 'PREV'); } function wpv_child_next() { return wpv_child(1, 'NEXT'); } function wpv_child($step, $label) { global $post; $parent = get_post_meta($post->ID, '_wpcf_belongs_parent_id', true); $children = get_posts(array('post_type' => 'child', 'meta_key' => '_wpcf_belongs_parent_id', 'meta_value' => $parent, 'numberposts' => -1)); foreach ($children as $i => $child) { if ($child->ID == $post->ID) break; } $i += $step; if (isset($children[$i])) return '<a href="' . get_permalink($children[$i]) . '">' . $label . '</a>'; } Relevant Documentation: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/ |
2 | 4 | 7 years, 5 months ago | ||
Clickable list of locations below map
1
2
Started by: Craig in: Toolset Professional Support |
2 | 26 | 7 years, 6 months ago | ||
Style taxonomy terms in a list
Started by: jeffreyS-5
in: Toolset Professional Support
Problem: Solution: wpv-post-taxonomy supports a separator. This is what you will use to create a list. You will need to open and close the List HTML tags in the separator argument. As example, this below in a Views Loop will produce a List of Terms names: <li>[wpv-post-taxonomy type='category' format='name' separator='</li><li>']</li> |
2 | 3 | 7 years, 11 months ago | ||
How to count repeated field?
Started by: Boris in: Toolset Professional Support |
2 | 6 | 8 years, 2 months ago | ||
Archive Page displaying too many results
Started by: joshM-4 in: Toolset Professional Support |
2 | 5 | 8 years, 2 months ago |