How do I sort private pages alphabetically

Accueil Forums Main plugin support How do I sort private pages alphabetically

20 sujets de 1 à 20 (sur un total de 21)
  • Auteur
    Messages
  • #527261
    Jim Young
    Participant

    Hello,

    Cant see how to sort private pages ascending alphabetically (A-B), currently they seem to be descending.

    #527420
    Thomas Lartaud
    Admin bbPress

    Hi,

    You’ll need to Modify the queries for private content listing.

    Hope that helps.

    Regards.

    #530518
    Jim Young
    Participant

    Thank you Thomas
    I am struggling to see the right file to edit here, if I update the main functions.php its bound to get overwritten at some point, but I cant locate cuar-functions.php

    With apologies, I am not good with code, could you clarify the code to sort the private pages section by Post title please.

    #531048
    Thomas Lartaud
    Admin bbPress

    Hi,

    Those instructions will help you to find where to put the code.

    Do not hesitate if you have more questions.

    Regards.

    #531560
    Jim Young
    Participant

    Thank you again, I have added the plugin and the sample code works as does removing a sidebar from the code snippets section, but I am suffering extreme pilot error with the sort order code. i put in..

    function cuar_custom_sorting_order( $args ) {
    $new_args = $args;

    // The next line says that the sort order will be by the date of the last modification
    // You could also sort by any field of the WordPress post table, like ‘title’
    $new_args[‘orderby’] = ‘title’;

    // This line says that we want to sort by descending order (opposite of ‘ASC’)
    $new_args[‘order’] = ‘ASC’;
    return $new_args;
    }

    // You can change the page slug to another one, for instance ‘customer-private-pages’ or ‘customer-conversations’
    $page_slug = ‘customer-private-pages’;

    But wordpress throws a “your site is experiencing technical difficulties” error – I’m sure I’m doing it wrong but I dont understand enough to know where or why

    Regards
    Jim

    #531696
    Thomas Lartaud
    Admin bbPress

    Hi,

    Can you put here the full content of your file, and paste it into a source code shortcode so it doesn’t get modified by the forum?

    source_code

    Regards.

    #531982
    Jim Young
    Participant

    Sorry for slow reply I made the mistake of replying to the email…

    {<?php
    /*
    Plugin Name: WPCA Custom Tweaks
    Plugin URI:
    Description: Just an example of a simple WP plugin that can be use to add code snippets for WP Customer Area
    Version:     1.0.0
    Author:      Thomas Lartaud
    Author URI:  https://wp-customerarea.com
    License:     GPL2
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    */
    
    defined('ABSPATH') or die('Nope, not accessing this');
    
    /**
     * Code snippet example
     * Remove the description field from the profile page
     *
     * @see https://wp-customerarea.com/code-snippets/ for more snippet examples
     *
     * @param $fields array Profile fields
     *
     * @return mixed array Modified profile fields
     */
    function remove_some_profile_fields( $fields )
    {
    	unset($fields[ 'description' ]);
    	return $fields;
    }
    
    add_filter('cuar/core/user-profile/get_profile_fields', 'remove_some_profile_fields');
    function cuar_disable_default_sidebar( $is_enabled ) {
      return false;
    }
    $page_slugs = array('customer-conversations', 'customer-private-files', 'customer-private-pages');
    foreach ($page_slugs as $page_slug) {
      add_filter( 'cuar/core/page/enable-default-sidebar?slug=' . $page_slug, 'cuar_disable_default_sidebar' );
    }
    function cuar_custom_sorting_order( $args ) {
        $new_args = $args;
    
        // The next line says that the sort order will be by the date of the last modification
        // You could also sort by any field of the WordPress post table, like 'title'
        $new_args['orderby'] = 'modified';
    
        // This line says that we want to sort by descending order (opposite of 'ASC')
        $new_args['order'] = 'DESC';
        return $new_args;
    }
    
    // You can change the page slug to another one, for instance 'customer-private-pages' or 'customer-conversations'
    $page_slug = 'customer-private-files';}

    This from the error log…
    [15-Aug-2019 06:15:49 UTC] PHP Fatal error: Cannot redeclare cuar_custom_sorting_order() (previously declared in /home/sludgetekco/public_html/wp-content/plugins/wpca-custom-tweaks/wpca-custom-tweaks.plugin.php:39) in /home/sludgetekco/public_html/wp-content/plugins/customer-area/skins/frontend/master/cuar-functions.php on line 478
    [15-Aug-2019 06:16:15 UTC] PHP Fatal error: Cannot redeclare cuar_custom_sorting_order() (previously declared in /home/sludgetekco/public_html/wp-content/plugins/wpca-custom-tweaks/wpca-custom-tweaks.plugin.php:39) in /home/sludgetekco/public_html/wp-content/plugins/customer-area/skins/frontend/master/cuar-functions.php on line 478
    [15-Aug-2019 06:16:17 UTC] PHP Fatal error: Cannot redeclare cuar_custom_sorting_order() (previously declared in /home/sludgetekco/public_html/wp-content/plugins/wpca-custom-tweaks/wpca-custom-tweaks.plugin.php:39) in /home/sludgetekco/public_html/wp-content/plugins/customer-area/skins/frontend/master/cuar-functions.php on line 478

    #532608
    Vincent Mimoun-Prat
    Admin bbPress

    You have declared a function with the same name in 2 different places.

    Please read carefully the error message to know where the other function is declared.

    You can either remove one of them if they are both functions you created, or rename the one you have created to something else.

    #532686
    Jim Young
    Participant

    Hi
    I’ve got rid of the duplicate and the whole file now reads as below, I have no error now but cannot see any pages (private-files are unaffected)
    The error log gives me…
    16-Aug-2019 06:00:00 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘cuar_custom_sorting_order’ not found or invalid function name in /home/sludgetekco/public_html/wp-includes/class-wp-hook.php on line 286
    [16-Aug-2019 06:00:00 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘cuar_custom_sorting_order’ not found or invalid function name in /home/sludgetekco/public_html/wp-includes/class-wp-hook.php on line 286
    [16-Aug-2019 06:00:50 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘cuar_custom_sorting_order’ not found or invalid function name in /home/sludgetekco/public_html/wp-includes/class-wp-hook.php on line 286
    [16-Aug-2019 06:00:50 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘cuar_custom_sorting_order’ not found or invalid function name in /home/sludgetekco/public_html/wp-includes/class-wp-hook.php on line 286

    But I dont know how to fix it

    entire file now looks like this…

    <?php
    /*
    Plugin Name: WPCA Custom Tweaks
    Plugin URI:
    Description: Just an example of a simple WP plugin that can be use to add code snippets for WP Customer Area
    Version: 1.0.0
    Author: Thomas Lartaud
    Author URI: https://wp-customerarea.com
    License: GPL2
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    */

    defined(‘ABSPATH’) or die(‘Nope, not accessing this’);

    /**
    * Code snippet example
    * Remove the description field from the profile page
    *
    * @see https://wp-customerarea.com/code-snippets/ for more snippet examples
    *
    * @param $fields array Profile fields
    *
    * @return mixed array Modified profile fields
    */
    function remove_some_profile_fields( $fields )
    {
    unset($fields[ ‘description’ ]);
    return $fields;
    }

    add_filter(‘cuar/core/user-profile/get_profile_fields’, ‘remove_some_profile_fields’);
    function cuar_disable_default_sidebar( $is_enabled ) {
    return false;
    }
    $page_slugs = array(‘customer-conversations’, ‘customer-private-files’, ‘customer-private-pages’);
    foreach ($page_slugs as $page_slug) {
    add_filter( ‘cuar/core/page/enable-default-sidebar?slug=’ . $page_slug, ‘cuar_disable_default_sidebar’ );
    }
    // You can change the page slug to another one, for instance ‘customer-private-pages’ or ‘customer-conversations’
    $page_slug = ‘customer-private-pages’;

    // Uncomment the add_filter line you need, depending on where you want to change the sorting order

    // 1. Change the order on the “My files” page (for any display mode)
    add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug, ‘cuar_custom_sorting_order’ );

    // 2. Change the order on the “My files” page (not when we are showing date archives or category archives)
    // add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug . ‘&display-mode=default’, ‘cuar_custom_sorting_order’ );

    // 3. Change the order on the “My files” page (when showing date archives)
    // add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug . ‘&display-mode=date_archive’, ‘cuar_custom_sorting_order’ );

    // 4. Change the order on the “My files” page (when showing category archives)
    // add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug . ‘&display-mode=category_archive’, ‘cuar_custom_sorting_order’ );

    // 5. Change the order on the “My files” page (when showing author archives)
    // add_filter( ‘cuar/core/page/query-args?slug=’ . $page_slug . ‘&display-mode=author_archive’, ‘cuar_custom_sorting_order’ );

    // 6. Change the order on the “Dashboard” page
    // add_filter( ‘cuar/core/dashboard/block-query-args?slug=’ . $page_slug, ‘cuar_custom_sorting_order’ );

    #532696
    Jim Young
    Participant

    Please ignore last post, I eventually spotted the missing code

    All working now

    Thank you

    #533293
    Thomas Lartaud
    Admin bbPress

    Glad you fixed it.

    Regards.

    #653136
    Jim Young
    Participant

    Hi
    The alphabetical sorting you assisted me with using the WPCA Custom tweaks plugin has worked for the last 6 months but now causes the available posts not to display.

    Is there an update I can do to resolve it?

    Many thanks
    Jim

    #653160
    Thomas Lartaud
    Admin bbPress
    Cette réponse a été marquée comme privée.
    #653195
    Jim Young
    Participant
    Cette réponse a été marquée comme privée.
    #653199
    Thomas Lartaud
    Admin bbPress
    Cette réponse a été marquée comme privée.
    #653230
    Jim Young
    Participant

    Hi
    I’ve disabled the plugin so the staff can use the portal

    If you re-enable they will go

    Jim

    #653231
    Jim Young
    Participant
    Cette réponse a été marquée comme privée.
    #653319
    Thomas Lartaud
    Admin bbPress

    Ok, thanks.

    I’ve been able to reproduce. I will look for a fix right now and let you know.

    Regards.

    #653358
    Thomas Lartaud
    Admin bbPress

    Could you please try to extract & to upload the attached file to customer-area/skins/frontend/master/assets/js/main.min.js (replace the existing one), try again (hit CTRL+F5 to refresh and clean cache), and tell me if it fixed your issue?

    Regards.

    Pièces jointes:
    1 utilisateur a remercié l'auteur de ce message.
    #653379
    Jim Young
    Participant
    Cette réponse a été marquée comme privée.
20 sujets de 1 à 20 (sur un total de 21)
  • Vous devez être connecté pour répondre à ce sujet.