Iurie Malai
Forum Replies Created
-
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] About the shortcodes_adverts_list() functionProbably I am wrong, but: can the adverts_the_content() function influence the excerpt when browsing by category? I do not understand fully how it works in the category related part.
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] About the shortcodes_adverts_list() functionThe same story with the_excerpt().
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] About the shortcodes_adverts_list() functionThank you, Greg! This is resolved. But I discovered a new and interesting issue: I added excerpts to items with get_the_excerpt() and this works well on main adverts list, but doesn’t when browsing by category. More precisely, when browsing by category nothing is displayed, excepting menus (see this). I don’t know if this is related to WP Adverts, but maybe you have an idea what happens.
This is how looks the mine customized list-item.php:
<div class="advert-item"> <?php $image = custom_adverts_get_main_image( get_the_ID() ) ?> <?php if($image): ?> <img src="<?php esc_attr_e($image) ?>" alt="" class="advert-item-grow alignleft" /> <?php else: ?> <img src="" alt="" class="placeholder alignleft" /> <?php endif; ?> <h2 title="<?php esc_attr_e( get_the_title() ) ?>" class="advert-link"><?php the_title() ?></h2> <a href="<?php the_permalink() ?>" title="<?php esc_attr_e( get_the_title() ) ?>" class="advert-link-wrap"></a> <span class="advert-excerpt">txt<?php echo(get_the_excerpt()); ?></span> <span class="advert-date"><?php echo date_i18n( get_option( 'date_format' ), get_post_time( 'U', false, get_the_ID() ) ) ?></span> <?php $price = get_post_meta( get_the_ID(), "adverts_price", true ) ?> <?php if( $price ): ?> <span class="advert-price"><?php esc_html_e( adverts_price( get_post_meta( get_the_ID(), "adverts_price", true ) ) ) ?></span> <?php endif; ?> </div>
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Locations dropdown menu in adverts listI figured out how to proceed. I created a text file with the desired select options for locations, that I can use with the “adverts_form_load” filter too, and just replaced the input field from the list.php template with the bellow code. Now I don’t need to keep two pieces of code with the same select options.
<?php $file_path = 'FILE_PATH_HERE'; // path to the file with select options if ( !file_exists( $file_path ) ) { echo '<input type="text" name="location" placeholder="' . __("Location ...", "custom-settings") . '" value="' . esc_attr($location) . '" />'; } else { $file_array = str_replace("\n","", file($file_path)); $options = '<option value="">' . __("Select a location ...", "custom-settings") . '</option>'; $options .= '<option value="0">' . __("All locations", "custom-settings") . '</option>'; foreach ($file_array as $location) $options .= '<option value="' . $location . '">' . $location .'</option>'; $select = '<select id="location" name="location">' . $options . '</select>'; echo $select; } ?>
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Hide the form if registration is not allowedSo, this is the [is_logged_in] shortcode function. It will display a message for not logged in users or the Add adverts page/form for logged in users. If registration is disabled the link ‘Register’ will not be displayed.
// The usage: [is_logged_in][adverts_add][/is_logged_in] // Hide Add Adverts page from not logged in users shortcode function is_logged_in_shortcode( $atts , $content = null ) { // check if user is not logged in if ( !get_current_user_id() ) { $permalink = get_permalink(); $message = __('Attention! Only logged in users can access this page.', 'wpadverts-custom-settings'); // check if registration is disabled if ( !get_option( 'users_can_register' )) { $message .= __(' <a class="button" href="%1$s">Login</a>', 'wpadverts-custom-settings'); } else { $message .= __(' <a class="button" href="%1$s">Login</a> or <a class="button" href="%2$s">Register</a>', 'wpadverts-custom-settings'); } $parsed = sprintf($message, wp_login_url( $permalink ), wp_registration_url( $permalink ) ); $message = adverts_flash( array( "error" => array( $parsed ) ) ); return $message; } return do_shortcode( $content ); } add_shortcode( 'is_logged_in', 'is_logged_in_shortcode' );
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Locations dropdown menu in adverts listI tried this. Nothing is displayed. Just ‘Keyword …’ input.
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Select advert category pagesSorry, but the above ‘pre_get_posts’ action was used in a wrong way. Finally, I found a theme specific action that worked both for single adverts and for custom taxonomy pages (both parents and children).
/* Add a Minn Lite theme 2-Column Sidebar Left template to custom * taxonomy pages and to single posts of the 'advert' custom post type */ function minn_lite_advert_template( ) { global $post; global $wpgo_global_column_layout; if ( $post->post_type == 'advert' || is_tax( 'advert_category' ) ) { $wpgo_global_column_layout = '2-col-l'; } } add_action( 'wpgo_after_content_open', 'minn_lite_advert_template' );
BTW, I found on wordpress.stackexchange.com that using globals to control theme features or to store any kind of data is a bad practice and not very safe coding. Good to know.
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Select advert category pagesOK, I found the right (I hope) solution:
/* Add a theme 2-Column Sidebar Left template */ // to archive pages of the 'advert' custom post type function my_advert_category_template() { global $wpgo_global_column_layout; if ( has_term( '', 'advert_category' ) ) { $wpgo_global_column_layout = "2-col-l"; } } add_action('pre_get_posts', 'my_advert_category_template' ); // to single 'advert' custom posts function my_advert_single_template( ) { global $post; global $wpgo_global_column_layout; if ( $post->post_type == 'advert' ) { $wpgo_global_column_layout = "2-col-l"; } } add_filter( 'single_template', 'my_advert_single_template' );
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Select advert category pagesGreg, sorry! I suppose that I use a wrong filter. Can you check?
My full code:
function my_advert_single_template( ) { global $post; global $wpgo_global_column_layout; if ( $post->post_type == 'advert' || is_tax( 'advert_category' ) ) { $wpgo_global_column_layout = "2-col-l"; } } add_filter( 'single_template', 'my_advert_single_template' );
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] account and recaptchaAfter a little thinking I ask myself: why to remove the Create Account line? By default it is displayed only for not logged in (eventually not-registered) users. If we will remove it, the hole form will become useless. Or not? I think, if you don’t want users to registers trough the adverts form, it must be made accessible only to registered users, as Greg suggested here.
Thank you very much!!!
P.S. Greg manages here an real WP Adverts Academy! ??
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Category Pages Not DisplayingNot all themes are compatible with all plugins. I also got this problem some time ago, and I fixed it changing the theme.
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Select advert category pagesI tried this, it doesn’t work. ??
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] account and recaptchaThe code works. I improved it a little, added the if(! get_option( “users_can_register”)) statement, so the Create Account line is removed only if registration is not allowed (Settings > General > Membership is not checked).
// Remove the Create Account line if registration is not allowed if ( ! get_option( "users_can_register" ) ) { add_filter( "adverts_form_load", "my_adverts_form_remove_create_account" ); function my_adverts_form_remove_create_account( $form ) { if($form["name"] != "advert") { return $form; } foreach($form["field"] as $k => $field) { if($field["name"] == "_adverts_account") { unset($form["field"][$k]); break; } } return $form; } }
I tried to replicate this behavior on my own site and everything is okay. I guess the cause of the problem is the theme or a plugin that you (luckyg) use.