joshM-4
Fils de soutien créés au cours des 30 derniers jours : 0
Sujets de forum favoris
Status | Sujet | Supporter | Voix | Publications | Nouveauté |
---|---|---|---|---|---|
Date fields from Events Manager are not interpreted as dates.
Commencé par : tammot
dans : Toolset Professional Support
Problem: Solution: You can find proposed solution, in this case, with the following reply: Relevant Documentation: |
2 | 13 | Il y a 5 années et 8 mois | ||
Editing a user's profile »?">how get the id of the previous post for Editing a user's profile »?
Commencé par : Mario
dans : 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 | Il y a 6 années et 7 mois | ||
Previous and Next Post Navigation when sorted by menu order
Commencé par : Shreyas Khatri
dans : 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 | Il y a 6 années et 11 mois | ||
Show most popular posts based on post view count
1
2
Commencé par : Nicholas
dans : 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 | Il y a 6 années et 11 mois | ||
How to show next / previous child post?
Commencé par : Amin
dans : 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 | Il y a 7 années | ||
Clickable list of locations below map
1
2
Commencé par : Craig dans : Toolset Professional Support |
2 | 26 | Il y a 7 années et 2 mois | ||
Style taxonomy terms in a list
Commencé par : jeffreyS-5
dans : 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 | Il y a 7 années et 7 mois | ||
How to count repeated field?
Commencé par : Boris dans : Toolset Professional Support |
2 | 6 | Il y a 7 années et 9 mois | ||
Archive Page displaying too many results
Commencé par : joshM-4 dans : Toolset Professional Support |
2 | 5 | Il y a 7 années et 10 mois | ||
Display ACF repeater fields via shortcode issue
Commencé par : joshD-2 dans : Toolset Professional Support |
2 | 3 | Il y a 8 années et 8 mois |