{"id":13984,"date":"2020-09-14T13:38:28","date_gmt":"2020-09-14T19:38:28","guid":{"rendered":"https:\/\/macblaze.ca\/?p=13984"},"modified":"2020-09-15T09:49:28","modified_gmt":"2020-09-15T15:49:28","slug":"theme-code-notes","status":"publish","type":"post","link":"https:\/\/macblaze.ca\/?p=13984","title":{"rendered":"Theme Code notes"},"content":{"rendered":"<h2>A few Macblaze.ca specific fixes<\/h2>\n<p>To get my Instagram posts to play nice with flex rather than floats I added<\/p>\n<pre><code>.category-instagram .post-content{\n\u00a0 display:flex;\n  flex-wrap: wrap;\n}<\/code><\/pre>\n<h3>Fixed the Headings CSS<\/h3>\n<h1>Heading 1<\/h1>\n<h2>Heading 2<\/h2>\n<h3>Heading 3<\/h3>\n<h4>Heading 4<\/h4>\n<h5>Heading 5<\/h5>\n<h6>Heading 6<\/h6>\n<p>&nbsp;<\/p>\n<h3>Ascending post order<\/h3>\n<h6>macblazev v 0.75.9<\/h6>\n<p>Back when I posted about <a href=\"https:\/\/macblaze.ca\/?p=8983\">changing the order<\/a> of certain categories and\/or all of them. But for some reason the feature seems to be missing from MacblazeIV which reversed the order on all categories. So I needed to put it back in.<\/p>\n<p>What I came up with is this. It goes in the category.php file after <code>if ( have_posts() ) <\/code> and allows me to specify which categories are sorted by ascending order and which are descending. This snippet also allows me to specify posts per page which I didn&#8217;t end up using but I left in here for posterity.<\/p>\n<pre><code>&lt; Changes display order for certain categories &gt;\n        \n\n    $thiscat =  get_query_var('cat'); \n        $catobject = get_category($thiscat); \n        $parentcat = $catobject->category_parent; \n        $slugname  = get_category($parentcat)->slug;\n\n                if (in_array($slugname, array('cat-1', 'cat-2')) || is_category(array('cat-3','cat-4')) ) {\n                    query_posts( $query_string.\"&orderby=date&order=ASC&posts_per_page=2\" ); \n                }<\/code><\/pre>\n<p>It&#8217;s based on <a href=\"https:\/\/stackoverflow.com\/questions\/19961130\/wordpress-how-to-get-parent-category-id\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/stackoverflow.com\/questions\/19961130\/wordpress-how-to-get-parent-category-id<\/a> and essentially finds the current category, finds the the id of the parent category then uses an <code>if statement<\/code> to check if that parent is one of the categories in the array. Then it checks to see if the current category is listed (without having a parent) as one that should also have an ascending order.<\/p>\n<p>Parents and individual categories are listed by their slugs.<\/p>\n<p>Right now the parents are: <code>array('Trips Etc.')<\/code> \u2014 so that all trips under that category read front to back \u2014 and the individual categories I want ascending are <code>array('its-novel','recipes-of-yore')<\/code>.<\/p>\n<p>All-in-all it works, but I need a more elegant solution.<\/p>\n<h4>Useful links for the future<\/h4>\n<ul>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/891238\/wordpress-php-way-to-test-if-pages-are-children-of-a-parent-page#comment698429_891284\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/stackoverflow.com\/questions\/891238\/wordpress-php-way-to-test-if-pages-are-children-of-a-parent-page#comment698429_891284<\/a><\/li>\n<li><a href=\"http:\/\/rachievee.com\/wp-tutorial-how-to-apply-a-template-to-sub-categories\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/rachievee.com\/wp-tutorial-how-to-apply-a-template-to-sub-categories\/<\/a><\/li>\n<li><a href=\"https:\/\/perishablepress.com\/6-ways-to-customize-wordpress-post-order\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/perishablepress.com\/6-ways-to-customize-wordpress-post-order\/<\/a><\/li>\n<li><a href=\"https:\/\/code.tutsplus.com\/tutorials\/wp_query-arguments-categories-and-tags--cms-23070\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/code.tutsplus.com\/tutorials\/wp_query-arguments-categories-and-tags&#8211;cms-23070<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A few Macblaze.ca specific fixes To get my Instagram posts to play nice with flex rather than floats I added .category-instagram .post-content{ \u00a0 display:flex; flex-wrap: wrap; } Fixed the Headings CSS Heading 1 Heading 2 Heading 3 Heading 4 Heading 5 Heading 6 &nbsp; Ascending post order macblazev v 0.75.9 Back when I posted about [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/13984"}],"collection":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13984"}],"version-history":[{"count":26,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/13984\/revisions"}],"predecessor-version":[{"id":14019,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/13984\/revisions\/14019"}],"wp:attachment":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}