Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter morfe1

    (@morfe1)

    I want to display the posts from the Primary category, which is set in the _yoast_wpseo_primary_category custom field with the category ID as value.

    1) Post “test16”:
    categories = blue, green, red, violet
    custom field key = _yoast_wpseo_primary_category
    custom field value = 9

    2) Post “test17”:
    categories = blue, green, red, violet
    custom field key = _yoast_wpseo_primary_category
    custom field value = 6

    (test16 has VIOLET as PRIMARY. And test17 – RED as Primary. I’ve set featured image for each post corresponding to it’s primary category color.)

    category IDs: blue(8), green(7), red(6), violet(9)

    Debugging is ON now.

    PS: I think the tests 13-16 look as if they are working because they were created in a row, all with violet as primary category. All the other posts were created one by one (blue, green, red, blue, green, etc)

    Plugin Author Aldo Latino

    (@aldolat)

    I think there is some misconception about what we are doing. ??
    Let’s dig into it.

    We want that, when viewing a single post, the sidebar displays the posts from the category that we have defined in the custom field key (=CFK) _yoast_wpseo_primary_category. The post we are viewing must have this CFK and also must be under the category defined in the CFK. This is our scope. Simple.

    Test for the post test16

    So, let’s look at the post Test16. This post:
    – has the CFK _yoast_wpseo_primary_category;
    – has the CFV (custom field value) 9 that is the ID of the category violet;
    – is under the category violet (and other categories, but this doesn’t affect our test).

    When viewing this post in the front-end, the sidebar should display posts from the category 9 i.e. violet.

    Let’s look if this is true. Let’s go to the post test16 and we see that the posts retrieved are 5:

    – test13
    – test14
    – test15
    – test16
    – test17

    If we look at the categories of this posts, we see:

    – test13 = blue, green, red, violet
    – test14 = blue, green, red, violet
    – test15 = blue, green, red, violet
    – test16 = blue, green, red, violet
    – test17 = blue, green, red, violet

    So the plugin is working right. He has grabbed posts that are under the category violet, which has the ID 9.

    Test for the post test17

    Let’s look at the post Test17. This post:
    – has the CFK _yoast_wpseo_primary_category;
    – has the CFV 6 that is the ID of the category red;
    – is under the category red (and other categories, but this doesn’t affect our test).

    When viewing this post in the front-end, the sidebar should display posts from the category 6 i.e. red.

    Let’s look if this is true. Let’s go to the post test17 and we see that the posts retrieved are 6 (notice the difference with the previous test where the posts retrieved were 5):

    – test1
    – test2
    – test3
    – test4
    – test5
    – test6

    All of these posts are under the category red which has ID 6.

    I hope that what I wrote is clear. ??

    Thread Starter morfe1

    (@morfe1)

    Oh, that makes sense, sorry) Tried removing the red from other posts and it worked by showing just the red ones.

    For some reason I thought that it’s supposed to pull the posts with the same category ID in _yoast_wpseo_primary_category (all posts, which have red as primary.)
    Got confused by the results of hidemyage.staging.wpengine.com.

    Do you know if there’s a way to display only the posts, which have the same category set as primary? Or mb better just to display them first. I thought about setting the order by meta_value_num but it’s doesn’t seem to work that way (mb I made something wrong but it gave the posts by date starting from 17th).

    Plugin Author Aldo Latino

    (@aldolat)

    Do you know if there’s a way to display only the posts, which have the same category set as primary?

    Not currently. I would require a new set of instructions, totally dedicated.

    I didn’t make a test for your case, but have you tried using the Widget Logic plugin? I explained a possible use here.

    Thread Starter morfe1

    (@morfe1)

    Don’t think this will work for me, because there are more than 150 categories but I will take a look, thanks!

    Anyway even 60-70% of correct articles is better than nothing)

    Thanks for your help! You’ve been awesome.

    Plugin Author Aldo Latino

    (@aldolat)

    You’re very welcome!

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Multiple Category order’ is closed to new replies.