Help with coding

This topic contains 28 replies, has 3 voices, and was last updated by  m forbes 10 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #8566

    m forbes
    Full Member
    Post count: 338

    I am wanting to have all CPTs and their assoc. categories visible to chose from on the Add Listings page, except the Events. I would like to have Events and their assoc. categories on the Add Event page, without the other CPTs.

    I used this in my child functions file:

    function geodir_add_listing_before_detail_fields(){

    global $post;

    $current_posttype = geodir_get_current_posttype();

    $geodir_allow_posttype = get_option(‘geodir_allow_posttype_frontend’);

    $post_types = geodir_get_posttypes(‘object’);

    $addlisting_links = ”;
    foreach($post_types as $key => $postobj){

    if(is_array($geodir_allow_posttype) && in_array($key, $geodir_allow_posttype) && count($geodir_allow_posttype) > 1){

    $name = $postobj->labels->singular_name;

    $checked = ”;
    if($current_posttype == $key)
    $checked = ‘checked=”checked”‘;

    $add_link = geodir_get_addlisting_link( $key );

    $addlisting_links .= ‘<div style=”display:block;line-height:30px; margin-right:5px; float:left;”>’;
    $addlisting_links .= ‘<input type=”radio” ‘.$checked.’ value=”‘.$add_link.'” title=”‘.ucfirst($name).'” name=”geodir_select_add_listing[]” onchange=”javascript:window.location=this.value;” >’.ucfirst($name);
    $addlisting_links .= ‘</div>’;

    }

    }

    if($addlisting_links != ”){ ?>

    <h5><?php _e(‘Select Listing Type’, GEODIRECTORY_TEXTDOMAIN);?></h5>

    <div class=”geodir_form_row clearfix”>
    <div id=”geodir_showposttypes” class=”geodir_showposttypes”>
    <?php echo $addlisting_links;?>
    </div>
    </div> <?php

    }

    }

    As was found here: https://wpgeodirectory.com/support/topic/one-link-only-for-custom-post-types/#post-8362

    And it does work, as it should, except it shows all CPTs in both the “Add Listing” page and the “Add Event” page. But I need it refined for my purposes and am not good enough at coding to do it correctly.

    Is there anyone who would like this job? Thanks!

    #8574

    purpleedge
    Expired Member
    Post count: 539

    Try changing this line to exclude events…

    if(is_array($geodir_allow_posttype) && in_array($key, $geodir_allow_posttype) && count($geodir_allow_posttype) > 1 && ($key<>’gd_event’) ){

    #8578

    m forbes
    Full Member
    Post count: 338

    Thank you so much for the suggestion, I really appreciate your help. Unfortunately it is not excluding the event option.

    #8581

    purpleedge
    Expired Member
    Post count: 539

    I’ve got the opposite problem 🙂

    I can’t get Events to show up in the Add Listing options!

    What do I have to do to get them to be available, then I’ll be able to have a closer look at the problem!

    OK, found it under Navigation. (Include rather than Exclude this time ??)

    #8582

    purpleedge
    Expired Member
    Post count: 539

    Just tested this line here and it seems to do what you want?

    if(is_array($geodir_allow_posttype) && in_array($key, $geodir_allow_posttype) && count($geodir_allow_posttype) > 0 && ($key<>’gd_event’) ) {

    Try adding this extra line to your code, where shown, below the foreach( line, and see what $key values you get listed, you should have one for “gd_event” …

    foreach($post_types as $key => $postobj){

    echo($key . ‘<br />’);

    #8583

    m forbes
    Full Member
    Post count: 338

    Humm, I get a little confused in the Navigation area when it comes to the post type navigation settings :). Probably because I have my Add Listing Link in a secondary menu. There is no option for this for the CPTs, as far as I can tell.

    Just seems to me that it should be easy to have all of the CPT options available on the add listing page, and not have to have a drop down of separate CPTs, but then sometimes I think different than others :).

    #8584

    purpleedge
    Expired Member
    Post count: 539

    I know what you mean, I don’t like the way the droplist works either and I might get some fresh ways to do it by looking at what you are doing.

    For instance, the droplist doesn’t expand in a sidebar if it is the last item in the sidebar, see attached, I’ll post it as a bug…

    #8591

    m forbes
    Full Member
    Post count: 338

    Are you sure it’s not a .css thing? My location changer looks like that, but it is all there, just can’t see the links unless I run the curser over it, it’s a .css thing, haven’t messed with it yet.

    #8592

    purpleedge
    Expired Member
    Post count: 539

    Seems to be, works OK in 2012 theme.

    Any luck with your code?

    #8625

    m forbes
    Full Member
    Post count: 338

    Well, I managed to get the white screen while trying something :), so no. I am hoping that someone here can help me. Anyone??

    #8626

    purpleedge
    Expired Member
    Post count: 539

    White screen sounds bad 🙂

    Copy and paste the function you have to a text file and upload it here.

    #8702

    Simone
    Expired Member
    Post count: 3515

    Hello, if I’ve understood what you’re talking about, you want to display all the CPT when adding a place (or a CPT) and to get rid of everything when selecting Event..is that right? see attachment 🙂

    #8721

    m forbes
    Full Member
    Post count: 338

    Hi Simone, yes, pretty much, EXCEPT I do NOT want the Events as an option on the Add Listing page. Screenshot attached.

    Hi Purpleedge, attached is the .txt file.

    And this is a new one… where the header used to say ‘Add Listing’, now it is reading “Add Marketplace”, which is what i changed the default places to but I cannot figure out why it is now reading “Add Marketplace”!!! I’ve tried so many varied settings, I can’t seem to figure out how to change this back!

    Thank you both very much!

    #8742

    Simone
    Expired Member
    Post count: 3515
    This reply has been marked as private.
    #8743

    m forbes
    Full Member
    Post count: 338

    Oh! Yes, this is exactly what I am looking for!

Viewing 15 posts - 1 through 15 (of 29 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount