Forum Replies Created

Viewing 15 posts - 151 through 165 (of 330 total)
  • Author
    Posts
  • in reply to: Piklist Taxonomy not working on WordPress 4.5 #6285
    Jason
    Keymaster

    @dillon To be clear, are you saying that taxonomy meta is not saving? Please provide more details if you can and how to reproduce. Thanks!

    in reply to: Meta box does not register #6284
    Jason
    Keymaster

    Hi! Unless something odd is caching, that isn’t something that is “reset”. Post types are registered every time WordPress handles a request, they’re not stored in the database. So if you change the post type it should be effective immediately. Make sure you’re changing the $post_types[] index, as that’s the string used for the registration, it’s not the slug.

    in reply to: Best Way to Display Select Value #6260
    Jason
    Keymaster

    Ok, I see what you’re looking for. There’s two ways you could do this:

    1. Split your field into three add-more group fields: one for Platinum, one for Gold, one for Silver. Then you simply pull in the meta for each one and they’re grouped how you want them.

    2. Sort the group results yourself and then loop through them:

    
    <?php
    $groups = get_post_meta($post->ID, 'summit_sponsor_group', true);
    $sorted_groups = array();
    foreach($groups as $group) {
      if ( !isset($sorted_groups[$group['sponsor_level']] ) {
        $sorted_groups[$group['sponsor_level']] = array();
      }
    
      $sorted_groups[$group['sponsor_level']][] = $group;
    }
    ?>
    
    <?php if ( !empty($sorted_groups['Platinum']) ): ?>
      <?php foreach($sorted_groups['Platinum'] as $group): ?>
        Platinum groups here
      <?php endforeach; ?>
    <?php endif; ?>
    
    <?php if ( !empty($sorted_groups['Gold']) ): ?>
      <?php foreach($sorted_groups['Gold'] as $group): ?>
        Gold groups here
      <?php endforeach; ?>
    <?php endif; ?>
    
    <?php if ( !empty($sorted_groups['Silver']) ): ?>
      <?php foreach($sorted_groups['Silver'] as $group): ?>
        Silver groups here
      <?php endforeach; ?>
    <?php endif; ?>
    

    You have a few different ways you could accomplish this, but they’ll look somewhat similar like that. This is more efficient than looping through the array multiple times as well.

    Hope this helps!

    in reply to: Best Way to Display Select Value #6258
    Jason
    Keymaster

    Ohhhhh… Got it. 🙂

    You would do something like this then:

    
    <?php
    $groups = get_post_meta($post->ID, 'summit_sponsor_group', true);
    foreach($groups as $group): ?>
    
    <?php if ( 'Platinum' === $group['sponsor_level'] ): ?>
      Platinum HTML here
    
    <?php elseif ( 'Gold' === $group['sponsor_level'] ): ?>
      Gold HTML here
    
    <?php else: ?>
      Silver HTML here
    
    <?php endif; ?>
    <?php endforeach; ?>
    

    Up above you’re checking against the whole group which is an array; you just want to see if the ‘sponsor_level’ index is Platinum, Gold, or Silver. Make sense?

    in reply to: Best Way to Display Select Value #6253
    Jason
    Keymaster

    I just noticed something.. in the piklist field you have the 'field' => 'sponsor_level', but then in the template you’re doing $sponsors = get_post_meta($post->ID, 'summit_sponsor_group', true);, which is then what you’re using to compare against the value to determine which section to show. I assume you mean summmit_sponsor_group to be sponsor_level?

    When in doubt, dump the value of the variable having the issue and see what value you’re getting. 🙂

    in reply to: Best Way to Display Select Value #6251
    Jason
    Keymaster

    You’re thinking in the right direction: grabbing the meta and then using it for your conditionals. To save on code you could do things like $gold_or_silver = in_array($sponsor, array('gold', 'silver')); and use that in a few places. It’s really all about how how you want to handle it from here. If the sections are distinctly different then what you’re doing is fine, otherwise you can try to reduce code where it makes sense.

    I’m also not entirely sure why you’re calling wp_reset_query at the end, but I assume you have a reason?

    Are you having a particular problem otherwise?

    in reply to: How to validate a settings section? #6203
    Jason
    Keymaster

    Hey @mandelkind!

    You should be able to accomplish the API check using the piklist_pre_option_update hook. As far as the notice text goes, however, I’m honestly not sure if you can change that. I’ll do a bit more digging, but Piklist may be using built-in WordPress functionality for that, and I’m not sure there’s a way to change the message. Not saying there isn’t for sure, though. You can, however, add your own notice to display in addition to the other.

    Hope this helps!

    in reply to: post to user relationships #6132
    Jason
    Keymaster

    Hi!

    My apologies, I should have talked to Steve before he posted and better explained my intention.

    I maintain that no, you don’t need to have a 'field' parameter for relates. In fact, I’m very surprised that Steve’s example worked.

    Please clear this up for me, though, when you say there are no database entries, do you mean there’s no __relate_post create for the rf_show meta? Have you tried just doing a get_posts query with suppress_filters set to false and using post_has/post_belongs?

    in reply to: post to user relationships #6112
    Jason
    Keymaster

    Hey!

    No problem. You’re obviously digging into it more than most and we’re glad to help clarify things.

    You’re correct when you say only a single object gets the relation row added to reflect a relationship — in fact it’s the object that belongs to the other that gets the row in its meta table. But, that doesn’t mean the relationships aren’t bidirectional. When you use the 'post_has', 'post_belongs', etc. query vars Piklist internally splits the query into two queries, using the former to determine the object’s relationships (given the direction has/belongs). So either the owner object is in the object’s meta, or the belonging object will have the object’s id in the meta — it works either way and is quite fast.

    This would be an example of a multiple select field that relates two posts:

    <?php
    /**
     * Title: Services Provided
     * Post Type: doctor
     * Context: side
     * Priority: low
     */
    
    piklist('field', array(
      'type'      => 'select',
      'template'  => 'field',
      'choices'   => piklist(get_posts(array(
        'post_type'   => 'service',
        'numberposts' => -1,
        'orderby'     => 'title',
        'order'       => 'ASC'
      )), array('ID', 'post_title')),
      'relate'    => array(
        'scope'     => 'post'
      ),
      'attributes'=> array(
        'multiple'  => 'multiple'
      )
    ));
    

    Let me know if that clears things up!

    in reply to: get_post_meta not working on CPT with custom post statuses #6108
    Jason
    Keymaster

    Ok, thanks. I mean, what’s really interesting to me is that the bug is that get_post_meta isn’t working, and that’s a very simple deal. If Piklist is presenting everything correctly, then I would say the problem lies somewhere in wp_insert_post, not Piklist. After wp_insert_post is called, what’s in the meta table for that new post? Is there something wrong with the field name? Is it there at all? Is it an empty value? Radio fields should simply store a single row with the value provided.

    I would start by analyzing the database after wp_insert_post is called and see why get_post_meta is returning empty (either there’s no value or there’s no row). Then I would go into the WordPress core and debug what’s happening in that function and see if there’s something strange going on in there — perhaps a filter is stripping the meta for some reason.

    Hope this helps!

    in reply to: post to user relationships #6107
    Jason
    Keymaster

    Hey @stemuedendron

    I believe you’re running into a change between 0.9.5.x and 0.9.9.x. Between the two versions we made it possible to turn any field into a relate field, so long as it ultimately provided an object ID, as well as opening relationships from just posts to all objects (e.g. user to post, as you’re doing).

    In 0.9.5.x it was possible to have a field with 'type' => 'relate' and 'field' => 'my_field' which would both store the value as meta and store the relationship. This wasn’t an intended feature, but I admittedly used it a couple times myself and it’s even something we’re considering bringing back.

    Now, in 0.9.9.x, relationships work different internally, which is why you’re not limited to the relate field type and can simply add the relate parameter to the field (as you’re doing). This did unfortunately “break” being able to relate and store meta at the same time, but seeing as it wasn’t something that was intentionally supported, it was considered acceptable. All that to say, keeping the 'field' parameter on a relate field now confuses things as relational fields are special. You shouldn’t need the meta as you can simply use the 'user_has','user_belongs', etc., parameter in your queries.

    Hope this helps!

    in reply to: get_post_meta not working on CPT with custom post statuses #6079
    Jason
    Keymaster

    Interesting, there isn’t anything particularly complicated going on here, so it should be a simple bug. Out of curiosity, what’s saving to the database when you save using the Piklist fields? I assume you’re using the PREFIX constant for those as well?

    in reply to: post to user relationships #6078
    Jason
    Keymaster

    Hey @stemuedendron

    You shouldn’t need the field parameter on either of them. Try removing that and see if it fixes it.

    in reply to: Where can I hire a Piklist expert? #6077
    Jason
    Keymaster

    Hello @cybermind75

    I’m one of the contributors of Piklist, and if you’re looking for paid assistance then feel free to email me at [email protected] to talk a bit more about what you’re looking for. My agency isn’t cheap, but we get it done right the first time. But it sounds like you have some fun ideas for Piklist! 🙂

    If, however, you’re looking for free or cheap solutions, then I’d encourage you to keep digging into PHP, as that seems to be a goal of yours. You can then get support on this forum as you come up to specific roadblocks and someone here, I’m sure, will be happy to help. Always great to learn!

    in reply to: post to post hierarchical relationships #6054
    Jason
    Keymaster

    Hey @friendlyfire3

    I would say via configuration no, but via convention yes. 🙂

    The relationships within Piklist are really pretty informal, working by a quick and simple convention via the meta tables to determine which object has another. Rather than trying to make Piklist a configuration monster that tries to have a formal way of defining every element of a relationship (i.e. one-to-one, hierarchical, etc.) we went simple and allow developers to take it however they’d want.

    All that being said, I’ve done similar sorts of relationships and simple break my overall query into multiple queries, and since I just want the id of the relationship, I limit the query to that (via the wp_query ‘fields’ => ‘ids’ parameter).

    $state = get_posts(array(
      'suppress_filters' => false,
      'post_type' => 'state',
      'numberposts' => 1,
      'has_post' => $city->ID,
      'fields' => 'ids'
    ));
    
    $country = get_posts(array(
      'suppress_filters' => false,
      'post_type' => 'country',
      'numberposts' => 1,
      'has_post' => $state
    ));

    Hope this helps!

Viewing 15 posts - 151 through 165 (of 330 total)