0
Welcome Guest! Login
0 items Join Now

Custom Post Order

  • Re: Custom Post Order

    Posted 11 years 5 months ago
    • atdny's Avatar
    • atdny
    • Rocketeer
    • Posts: 53
    • Thanks: 0

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • chrisrth wrote:
      That's great. So I can just copy the contents of category.php to [MYSLUG].php and edit the query as needed for that category only. Gantry will load the custom php file automatically, correct?


      I would like to use the category sorted alpha functionality on a WP Zephyr template installation. I can only find (wp-includes/category.php) in my installation

      I have copied this file and made category-suffolk.php

      I would like to have category-suffolk.php return with categories sorted alpha. Can you please post an example of what category-suffolk.php should contain to do so? It definitely would be great if this was in the content>category settings of gantry!
    • Shazdeh's Avatar
    • Shazdeh
    • Elite Rocketeer
    • Posts: 4984
    • Thanks: 29

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • Hi atdny,
      To change the sort order you can add this snippet to your theme's functions.php file:
      function custom_category_sort_order( $query ) {
           if( $query->is_category( 'suffolk' ) ) {
                $qurry->set( 'orderby', 'title' );
           }
      }
      add_action( 'pre_get_posts', 'custom_category_sort_order' );
      The snippet changes the query on the "suffolk" category archive page to be sorted by their title.
    • Please don't PM unless requested ;)
      Consider using the custom stylesheet for all your CSS customizations: gantry-framework.org/documentation/wordp...custom_stylesheet.md .
      Please provide the URL to the issue.
      And please mark the thread as solved if the issue is resolved.
    • atdny's Avatar
    • atdny
    • Rocketeer
    • Posts: 53
    • Thanks: 0

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • no matter how i tried to enter this code, it broke my site. Please enter as you see fit below. I very much appreciate your help Shazdeh!


      <?php
      /**
      * @version 1.4 November 13, 2012
      * @author RocketTheme www.rockettheme.com
      * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
      * @license www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
      */

      /**
      * Check to see if Gantry is Active
      *
      * @return bool
      */
      function gantry_theme_is_gantry_active()
      {
      $active = false;
      $active_plugins = get_option('active_plugins');
      if (in_array('gantry/gantry.php', $active_plugins)) {
      $active = true;
      }
      if (!function_exists('is_plugin_active_for_network'))
      require_once(ABSPATH . '/wp-admin/includes/plugin.php');
      if (is_plugin_active_for_network('gantry/gantry.php')) {
      $active = true;
      }
      return $active;
      }

      /**
      * @return void
      */
      function gantry_admin_missing_nag()
      {
      $msg = __('The active theme requires the Gantry Framework Plugin to be installed and active');
      echo "<div class='update-nag'>$msg</div>";
      }

      /**
      * @return void
      */
      function gantry_missing_nag()
      {
      echo "This theme requires the Gantry Framework Plugin to be installed and active.";
      die(0);
      }


      if (!gantry_theme_is_gantry_active()) {
      if (!is_admin()) {
      add_filter('template_include', 'gantry_missing_nag', -10, 0);
      }
      else {
      add_action('admin_notices', 'gantry_admin_missing_nag');
      }
      }
      ?>
    • Shazdeh's Avatar
    • Shazdeh
    • Elite Rocketeer
    • Posts: 4984
    • Thanks: 29

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • atdny's Avatar
    • atdny
    • Rocketeer
    • Posts: 53
    • Thanks: 0

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • I've installed and used safecode, and the site just becomes a white page once the code is inserted. Can you insert the code below to see if it is me or a problem with the code? Your help is greatly appreciated on this!

      <?php
      /**
      * @version 1.4 November 13, 2012
      * @author RocketTheme www.rockettheme.com
      * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
      * @license www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
      */

      /**
      * Check to see if Gantry is Active
      *
      * @return bool
      */
      function gantry_theme_is_gantry_active()
      {
      $active = false;
      $active_plugins = get_option('active_plugins');
      if (in_array('gantry/gantry.php', $active_plugins)) {
      $active = true;
      }
      if (!function_exists('is_plugin_active_for_network'))
      require_once(ABSPATH . '/wp-admin/includes/plugin.php');
      if (is_plugin_active_for_network('gantry/gantry.php')) {
      $active = true;
      }
      return $active;
      }

      /**
      * @return void
      */
      function gantry_admin_missing_nag()
      {
      $msg = __('The active theme requires the Gantry Framework Plugin to be installed and active');
      echo "<div class='update-nag'>$msg</div>";
      }

      /**
      * @return void
      */
      function gantry_missing_nag()
      {
      echo "This theme requires the Gantry Framework Plugin to be installed and active.";
      die(0);
      }


      if (!gantry_theme_is_gantry_active()) {
      if (!is_admin()) {
      add_filter('template_include', 'gantry_missing_nag', -10, 0);
      }
      else {
      add_action('admin_notices', 'gantry_admin_missing_nag');
      }
      }
      ?>
    • Shazdeh's Avatar
    • Shazdeh
    • Elite Rocketeer
    • Posts: 4984
    • Thanks: 29

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • Hi atdny,
      I've attached a copy of the functions.php file with the snippet added. Please replace it with the original functions.php file of the theme and that should do it.
    • Please don't PM unless requested ;)
      Consider using the custom stylesheet for all your CSS customizations: gantry-framework.org/documentation/wordp...custom_stylesheet.md .
      Please provide the URL to the issue.
      And please mark the thread as solved if the issue is resolved.
    • atdny's Avatar
    • atdny
    • Rocketeer
    • Posts: 53
    • Thanks: 0

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • Shazdeh, your change does seem to work, however it seems to be sorting from z-a. I have been searching php.net/ on how to change this to sort from a to z but cant figure it out. If I can get this to sort alpha, that would be fantastic. Any additional help would be very appreciated.
    • atdny's Avatar
    • atdny
    • Rocketeer
    • Posts: 53
    • Thanks: 0

    Re: Custom Post Order

    Posted 11 years 1 month ago
    • Hello Shazdeh, should I be posting this request elsewhere? Any help would be appreciated!

Time to create page: 0.058 seconds