Archive-Pro-Matic Pretty URL Rewrite

The goal is to change an ugly archive url into a pretty url. For example here is a quarterly custom post type archive:

    The links are in a format of:

    https://spacedonkey.de/date/2012/?q=4&post_type=monkey

    And they would look better with something like:

    https://spacedonkey.de/monkey/2012/Q4

    To accomplish this, first the Add rewrite rules must be checked on the Archive-Pro-Matic settings page:

    After the CPT Rewrite Rules has been checked and saved. It might be necessary to flush the rewrite rules by simply navigating to:
    Dashboard > Settings > Permalinks – do nothing, and re-save the permalink settings.

    Second a custom url rewrite function must be added to the child-theme’s function.php file. This function uses a new filter that has been added to manually overwrite the url that archive-pro-matic uses:

    add_filter('apm_archive_link', 'pretty_my_archive_url');
    function pretty_my_archive_url($url){
        $url_args = explode('?', $url);
        if(!empty($url_args[1])){
           parse_str($url_args[1], $args);
           if(!empty($args['year']) && !empty($args['q'])){
              $url = $url_args[0].$args['year'].'/Q'.$args['q'].'/';
           }
        }
        return $url;
    }

    Now, when we display a quarterly archive for a custom post type, the urls are prettier:

    [archives type="quarterly" post_type="donkey" /]

      And here is a test of just using the standard yearly archive for a custom post type:

      [archives post_type="donkey" /]

      Archive Pro Matic Exclude Single Cat

      Test to see if a single category can be excluded from an archive list.

      [archives type="monthly" cat_id="-51"/]

      Archive-Pro-Matic Monthly Sub Post-By-Post

      This is a test of a monthly archive that displays a sub-list of post-by-post archives.

      [archives type="postbypost" sub_options="true" limit="10"/]

      Categories

      Here are examples of limiting by category. First, using cat_id

      [archives type="postbypost" sub_options="true" cat_id="55" limit="10"/]

      Taxonomies

      Next, Using taxonomy and term. This pair can be used for any taxonomy, including category:

      [archives type="postbypost" sub_options="true" taxonomy="category" term="archive-pro-matic" limit="10"/]

      Print-Pro-Matic Optional No-Print

      In this example, the option to include a specific element is provide by using a checkbox. This feature was introduced in Print-Pro-Matic version 2.0-beta-210121

      The default print target will be the article element. The image of the donkey has been assigned a class of ‘logo’. Now we need to create our print trigger and a checkbox:

      [print-me title="Print Trigger"/]
      
      <label><input type="checkbox" id="ppm_odnp" value=".logo">Donkey Free Print</label>

      The checkbox must have an ID of ppm_odnp (because print-pro-matic optional do not print is a bit long). The value is the optional do not print selector, so .logo is for items with a class of ‘logo’, while #logo is an item with an id of ‘logo’.

      Here is a working demonstration.

      Print Trigger