Help with coding
This topic contains 28 replies, has 3 voices, and was last updated by m forbes 10 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: Add Event, add listings
-
AuthorPosts
-
July 15, 2014 at 10:16 pm #8566
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!
July 16, 2014 at 1:15 am #8574Try 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’) ){
July 16, 2014 at 2:15 am #8578Thank you so much for the suggestion, I really appreciate your help. Unfortunately it is not excluding the event option.
July 16, 2014 at 2:43 am #8581I’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 ??)
July 16, 2014 at 2:53 am #8582Just 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 />’);
July 16, 2014 at 2:57 am #8583Humm, 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 :).
July 16, 2014 at 3:07 am #8584I 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…
July 16, 2014 at 3:27 am #8591Are 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.
July 16, 2014 at 3:33 am #8592Seems to be, works OK in 2012 theme.
Any luck with your code?
July 16, 2014 at 6:37 am #8625Well, I managed to get the white screen while trying something :), so no. I am hoping that someone here can help me. Anyone??
July 16, 2014 at 6:44 am #8626White screen sounds bad 🙂
Copy and paste the function you have to a text file and upload it here.
July 16, 2014 at 6:07 pm #8702Hello, 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 🙂
July 16, 2014 at 7:57 pm #8721Hi 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!
July 16, 2014 at 10:14 pm #8742This reply has been marked as private.July 16, 2014 at 10:29 pm #8743Oh! Yes, this is exactly what I am looking for!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket