Custom WordPress theme not displaying posts from category

I am creating a custom WordPress theme and as far as I can remember WordPress is supposed to do the heavy lifting for filtering of post types by their category, author, etc. on it’s own. This is just an altered query from my index.php specifically for category types.

Another question… do I even need an archive.php? I thought WordPress was supposed to do all the heavy lifting as far as filtering by categories, tags, authors, etc. My index.php works great, but when I tried to go to a specific category it was showing all of my posts and not just the selected category so I tried implementing an archive.php

EDIT 1: I should have mentioned I’m not using the main loops because I’m using custom post types

archive.php

<?php /**  * @author    Mark Abel  * @package   client-name/archive  * @version   1.0  */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly get_header(); ?>  <?php get_template_part( 'partials/partial', 'sidenav' );?>  <section class="masonry__container" id="masonry__container">   <div class="masonry" id="masonry">     <?php       $  category = get_category( get_query_var( 'cat' ) );       $  cat_id = $  category->cat_ID;       $  loop = new WP_Query( array( 'post_type' => 'project', 'cat' => $  cat_id ) );       if ( $  loop->have_posts() ) :         while ( $  loop->have_posts() ) : $  loop->the_post(); ?>           <?php $  project_for = get_post_meta($  post->ID, "project_for", true); ?>           <article class="masonry__tile" data-aos="zoom-in">             <img src=<?php the_post_thumbnail_url(); ?> alt="an image" />               <div class="masonry__overlay"><div class="masonry__title">                 <?php echo get_the_title() ?>               </div>               <div class="masonry__project">                 <?php echo $  project_for ?>               </div>               <span></span>               <div class="masonry__cta"><a href="<?php echo get_post_permalink(); ?>">Click to view</a></div>               <a class="masonry__video" href="https://player.vimeo.com/video/124254859">Play video</a>             </div>           </article>         <?php endwhile;       endif;       wp_reset_postdata();     ?>   </div> </section>   </body>  <!-- Footer -->  <?php get_footer(); ?>  </html> 

partial imported by index.php

<?php /**  *  @author    Mark Abel  *  @package   client-name/partials/partial-masonry  *  @version   1.0  */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>  <section class="masonry__container" id="masonry__container">   <div class="masonry" id="masonry">     <?php       $  loop = new WP_Query( array( 'post_type' => 'project' ) );       if ( $  loop->have_posts() ) :         while ( $  loop->have_posts() ) : $  loop->the_post(); ?>           <?php $  project_for = get_post_meta($  post->ID, "project_for", true); ?>           <article class="masonry__tile" data-aos="zoom-in">             <img src=<?php the_post_thumbnail_url(); ?> alt="an image" />               <div class="masonry__overlay"><div class="masonry__title">                 <?php echo get_the_title() ?>               </div>               <div class="masonry__project">                 <?php echo $  project_for ?>               </div>               <span></span>               <div class="masonry__cta"><a href="<?php echo get_post_permalink(); ?>">Click to view</a></div>               <a class="masonry__video" href="https://player.vimeo.com/video/124254859">Play video</a>             </div>           </article>         <?php endwhile;       endif;       wp_reset_postdata();     ?>   </div> </section> 

Is Python’s Grammar in a known Category between CFG and CSG?

I have a high level understanding of formal languages and grammars, and I’m familiar with the four major types of grammars in Chomsky hierarchy. I was interested in knowing the classification of Python’s grammar. A quick search yielded some quick, but incomplete answers.

http://trevorjim.com/python-is-not-context-free/

I’ve heard of context-free grammars (CFGs), but are context-sensitive grammars used in any applications? from compsci

Is Python a context-free language?

The immediate takeaway from most resources it that Python’s grammar is not a context free grammar (CFG). But that doesn’t answer the question of what it is. Looking deeper I found that its a complete context sensitive grammar (CSG) either. But still no classification.

At this point the conclusion was that there must exist classes of grammars between CFGs and CSGs, but I had never heard anything about these.

What I do understand is Python’s lexer (which transforms character sequences into tokens) does something that a CFG cannot do: it tracks the level of indentation and yields special INDENT DEDENT tokens. After this transformation resulting tokens are context-free and can be parsed into an abstract syntax tree. Thus the grammar on tokens is a CFG, but the grammar on characters uses slightly power power than a CFG can provide alone. I want to know if there is a classification for this type of grammar. What is between a CFG and a CSG?

After a bit more searching I stumbled on this table at the bottom of a Wikpedia article: https://en.wikipedia.org/wiki/Linear_bounded_automaton#External_links

Here is an image of that table:

enter image description here

Cool, I found that there are known grammars between CFG and CSGs. But I’m not an expert on formal languages, so I don’t know how I would go about determining which if any of these categories Python’s grammar belonged to.

Is it a “Positive range concatenation”, “Indexed”, “Thread automation’s Grammar”, “Linear context-free rewriting system”, “Tree-adjoining”? Is it none of these; if so does what it is have a classification?

Note: The full grammar specification of Python 3 can be found here: https://docs.python.org/3/reference/grammar.html

What size category is a reduced Tarrasque?

The rule for a creature’s size is as follows on Monster Manual page 6:

$ $ \begin{array}{lll} \textbf{Size} & \textbf{Space} & \textbf{Examples} \ \hline \text{Tiny} & \text{2½ by 2½ ft.} & \text{Imp, sprite} \ \text{Small} & \text{5 by 5 ft.} & \text{Giant rat, goblin} \ \text{Medium} & \text{5 by 5 ft.} & \text{Orc, werewolf} \ \text{Large} & \text{10 by 10 ft.} & \text{Hippogriff, ogre} \ \text{Huge} & \text{15 by 15 ft.} & \text{Fire giant, treant} \ \text{Gargantuan} & \text{20 by 20 ft. or larger} & \text{Kraken, purple worm} \ \end{array} $ $

The Monster Manual page 268 states:

A scaly biped, the tarrasque is fifty feet tall and seventy feet long, weighing hundreds of tons.

And the Reduce use of the Enlarge/Reduce spell states:

The target’s size is halved in all dimensions, and its weight is reduced to one-eighth of normal. This reduction decreases its size by one category – from Medium to Small, for example.

Emphasis mine.

In the case of our Tarrasque, these statements in Reduce are contradictory. Its new size is now 25′×35′, which means it’s still classified as Gargantuan.

Which rule takes priority?

We can break the rules even more here. If we assume the Tarrasque is now huge rather than gargantuan, PHB 192 states:

Squeezing into a Smaller Space: A creature can squeeze through a space that is large enough for a creature one size smaller than it. Thus, a Large creature can squeeze through a passage that’s only 5 feet wide. While squeezing through a space, a creature must spend 1 extra foot for every foot it moves there, and it has disadvantage on attack rolls and Dexterity saving throws. Attack rolls against the creature have advantage while it’s in the smaller space.

This means our 25′×35′ beastie can now get through a 10 foot door.

Inserting Ultimate member username as WooCommerce category into Ultimate member page

The website in question are using the Ultimate User plugin.

I am interested in installing WooCommerce and create a WooCommerce category for each Ultimate Member (Subscriber). (If there also is an easy way to auto-generate the category when users register, just yell it out!).

Is there a way to insert (based on the WooCommerce shortcodes):

[products limit="12" columns="4" orderby="popularity" category="CURRENT USER PROFILE"] 

And maybe a button for “see all products” (in the same category).

So that if a user is selling something, their products will displayed on the profile.

I´m not sure what the best approach for this. I was thinking about stripping the current URL /user/exampleuser/ – so that exampleuser is extracted and inserted into the shortcode.

Thank you for any input!

Thanks in advance!

Should I add category page number to breadcrumbs on product page

I am currently working on a website which has paginated content. It is a list of products. There are many categories, but for simplicity, let’s assume that I have just one category with many pages.

I have implemented pagination in such a way that search engines can index it. Here is my implementation:

  1. prev/next meta tags.
  2. canonical URL pointing to itself (i.e. first page points to itself, and second page points to itself as well).
  3. there are no blocks on indexing of ?page= pages.
  4. Breadcrumbs for the first page are Main > Category, but for all other pages they are Main > Category > Page X.
  5. Breadcrumbs are also added to structured data, and I also have an ItemList structured data item representing the list of products which is displayed.

It all works as expected. However, currently, all my products have the following breadcrumbs: Main > Category > Product X regardless of whether my product appears on the first page or not. I was wondering whether there is any SEO benefit in changing these to Main > Category > Page X > Product for the products which do not appear on the first page of my category?

I think that this would be a welcome change from a UI point of view, but I am worried that it might negatively affect my SEO. Also, I am worried that it might make my structured data breadcrumbs somewhat worse. Google does show them in the search results, and I am not sure that Page X would be a great detail to put there for a product path 🙂

Does anyone have any thoughts/experience about this matter?

Category archive rewrite rule to include category/subcategory?

I’d like to have my category archive (category.php) accessible using via a url structure like:

mysite.com/mycategory/mysubcategory

For example, I’ve got “health” as a category and “smoking” as its subcategory. The following:

  • mysite.com/health
  • mysite.com/smoking
  • (and even) mysite.com/category/health/smoking

all work fine.

But mysite.com/health/smoking gets a 404.

Is there something under Settings->Permalinks that will fix this? Do I need to put a rewrite rule of some kind in functions.php?

Thanks.

Show all posts of sub category in a page like: foo.com/category/subcategory/ using UNCODE Theme

I’ll be upfront and say that this is a difficult question to phrase for achieving the “correct” answer as it seems it can be done a few ways.

I am using the WP Theme Uncode from undsgn.com that uses the WP Bakery Page Builder / Visual Composer. Here is a brief how-to video that shows the module as part of the theme to query each archive type. https://www.youtube.com/watch?v=M8_H2neBRRA

I want to create categories and subcategories within the Posts section to differentiate the posts: https://toddsines.com/direction/ <– lists all Direction spots direction https://toddsines.com/direction/mv/ <– Should list all Music Videos I directed, but instead throws a 404 error.

 direction/fashionfilms I tried looking into tweaking the Uncode child theme functions.php, category.php, archive.php and category-$ slug.php, as well as some specific subcategory PHP files to show just the results of 1 Subcategory instead of the Parent category to no avail. Page template in two level deep folder

I tried to follow this and it is way over my head [I’m a director/photographer/musician, not really a developer, but will get my hands dirty when necessary] How to create a category and sub-category sorted blogroll with all posts?

Additionally, I saw that the developer in the StackExchange link tried to automatically create archives of categories without having to hard-code each and every subcategory, because they may expand, shrink, renamed or reorganized. So making custom content blocks, then making custom pages to display that custom content block within the Uncode theme’s post/page builder seems redundant given that the work is being categorized in the post as each post is made.

I am surprised that this functionality is not standard practice. I tried looking for plugins and I clearly cannot find the right flavor of queries or something that does not break the Uncode theme to achieve my desires. I would prefer an elegant example — don’t we all?

  1. I DO NOT want a text list.
  2. I want it to look exactly like the examples above and in the YouTube clip — aka styled buttons with animations, CSS-styled text overtop regenerated thumbnails from the media library, etc.
  3. I have fought with WP for the last 4 days trying to figure this out 🙁

My only option to achieve the thumbnail display as shown, is to create Query-based content blocks for each division [subcategory] of work, such as Commercials, in a parent category, such as Direction.

  1. Create the query content block showing just Commercials
  2. Create page to show that content block
  3. Add link in menu to link to the page to show Commercials

It would ideal to make a subcategory page template that automatically creates a nice looking index with the work in each subcategory without me having to do independent queries of everything.

Thanks for your help in advance!

Todd

Hide some Category in wp_query

I have created in new custom post type. Now I want to show all the posts in one page. But I want to hide in some category’s post in that. How could I do that?

                                $  args_post = array(                                     'post_type' => 'products',                                      'posts_per_page' => -1,                                     'post_status' => 'publish',                                      'orderby' => 'publish_date',                                      'order' => 'ASC',                                     'tax_query' => array(array(                                          'taxonomy' => 'product_categories',                                          'field' => 'slug',                                          'terms' => 'new_term'                                         )                                     )                                 );