Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • in reply to: adding tags to custom post types #11137

    Thanks @sbruner, that did the trick!

    I’ll also note if one wants different types of posts to show up together in various listings (like for authors, archives, etc), one has to make that happen with something like:

    add_filter( ‘pre_get_posts’, ‘lm_archive_author’ );
    function lm_archive_author( $query ) {
    if ( ( !is_admin() && $query->is_main_query() ) && ( is_front_page() || is_tax() || is_author() || is_archive() ) ) {
    $query->set( ‘post_type’, [‘resource’, ‘post’] );
    return $query;

    in reply to: adding tags to custom post types #11134

    I’m having trouble with what I think is the same need: to have a custom post type use the same stock tags taxonomy used by standard posts.

    Based on the documentation I’ve read, it seems like I only need to include the tags taxonomy when I register the custom post type (see below). It doesn’t seem like I need to register the existing tags taxonomy (ie, using “piklist_taxonomies”) also, as that seems to create yet another tags taxonomy in addition to the stock tags taxonomy.

    However, when I register the custom post type with the tags taxonomy, CPT posts don’t appear under the stock tags taxonomy archive.

    // Resources via Piklist: Add resource custom post type.
    add_filter(‘piklist_post_types’, ‘lm_resource_post_type’);
    function lm_resource_post_type($post_types) {
    $post_types[‘resource’] = array(
    ‘labels’ => piklist(‘post_type_labels’, ‘Resource’)
    ,’title’ => __(‘Enter a new resource title’)
    ,’menu_icon’ => piklist(‘url’, ‘piklist’) . ‘/parts/img/piklist-menu-icon.svg’
    ,’page_icon’ => piklist(‘url’, ‘piklist’) . ‘/parts/img/piklist-page-icon-32.png’
    ,’supports’ => array(
    ,’public’ => true
    ,’admin_body_class’ => array(
    ,’has_archive’ => true
    ,’rewrite’ => array(
    ‘slug’ => ‘resources’
    ,’capability_type’ => ‘post’
    ,’edit_columns’ => array(
    ‘title’ => __(‘Resource’)
    ,’author’ => __(‘Contributed by’)
    ,’taxonomies’ => array(‘post_tag’)
    return $post_types;

    in reply to: Widgets not displaying after Piklist #6271

    On further investigation, it seems a widgets settings file needs to be present for each Piklist widget and that file needs to contain at least one Piklist widget field or other code for that widget to display.

    If the settings file is now necessary, all widgets documentation may need to be updated.

    WP 4.4.2, Piklist

    in reply to: Widgets not displaying after Piklist #6270

    I take it back, apparently a widget settings file does need to be present for one’s widgets to display.

    in reply to: change related post? #6268

    I’m now able to effectively manage post-to-post (PTP) relationships programmatically via my own custom function.

    As things stand in Piklist, posts are related by setting postmeta values on the __relate_post key. So for example, if post ID 1 were related to post ID 2, there would be these two rows in the wp_postmeta table:

    post_id, meta_key, meta_value
    1, __relate_post, 2
    2, __relate_post, 1

    And one can set/unset such postmeta values using standard WP functions like:

    // add a specific PTP relationship
    update_post_meta($postID, '__relate_post', $postIDrelated);
    // remove a specific PTP relationship
    delete_post_meta($postID, '__relate_post', $postIDrelated);

    Note that each relationship sets two postmeta values, one for each related post relating it to the other. Obviously there may be many relationships for any given post to any number of other posts, so to change more/all relationships, one would have to do some querying/looping to make broader changes. Read up on on how update_post_meta and delete_post_meta work to understand how to change one or more relationships.

    : Thanks for the help! I consider this inquiry resolved.

    in reply to: change related post? #6206


    I see in the latest Piklist beta that @sbruner guided me to that post-to-post relationships are no longer stored in a separate table, but in wp_postmeta. That makes it more obvious how to change relationship values via a custom function. I’ll experiment and post my results.

    in reply to: change related post? #6187

    @gabzon & @sajonara: It seems like you both were looking to do something similar to what I’m attempting. I was hoping to use the CPT-CPT relation standard in Piklist rather than storing the relation in a separate meta field as in @sajonara’s solution.

    Have either of you discovered a way to make a standard Piklist relation via a function?

    in reply to: change related post? #6179

    Thanks @sbruner! I got the latest beta and it definitely appears to be a quantum leap!

    Maybe I’m blind, but still not finding an obvious way to change related posts other than the metabox.

    My use case is to send a user from an instance of one CPT (let’s call it the parent) to a very large collection of posts of another CPT (let’s call them the children), one of which the user would select to relate to the original parent CPT. The user might also need to make a new child to relate.

    It seems like too much to try to handle that all via the parent form, so I’m using sessions to enable the user to leave the parent, explore the children, and choose a child to relate to the parent.

    I’m looking for a way to have a form button (or link) on the child that fires a function that relates that child back to the parent (which is known in the session). I just can’t seem to find the right call to make in my function to establish the relation to the parent. Do I have to update the wp_post_relationships table myself, or is there function that already does that?

Viewing 8 posts - 1 through 8 (of 8 total)