Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Get images based on TAG

Discussion in 'Misc WordPress Requests' started by bcworkz, Jan 15, 2018.

  1. bcworkz

    Guest

    Reply To: Get images based on TAG, by bcworkz

    Heya back at ya! Despite the lack of an initial greeting, I do remember you, unlike our last interaction. I didn’t realize it had been a long time. That loop question seems like it was only a couple weeks ago, not nearly a dozen weeks o_O

    Thanks for the example, that’s helpful. For that to all work, you would need a custom page template and either a custom sidebar template or widget.

    The list of posts from the main query should still be in the global $wp_query object when your widget or sidebar code runs, unless some other code failed to reset their secondary query properly. You can loop through the list and accumulate the tags of each post, disregarding duplicates, or removing them afterwards. From the accumulated, distinct tags you can output a tag list with links to our custom page that includes the specific tag as a query arg.

    Even better, but more complicated, would be to send an Ajax request when any tag is clicked. The returned data is used to re-display featured images and re-generate a new tag list.

    When either the Ajax request or custom page request is received, the passed tag term is used to make a query for all posts having the assigned tag and having a featured image assigned. The result is used to generate a list of images that are displayed in the main content area.

    A new tag list is generated from the new list of posts/images. The cycle can be repeated for as long as the user has patience.

    I’m unsure of your coding skill level. Even the best make rookie mistakes once in a while. I imagine my description could sound hopelessly complicated. There are a lot of pieces to this puzzle, but if you focus on one part at a time, it’s all attainable. It just might take a while. There is some opportunity for simplification. You can always embellish further after the initial functionality is achieved.

    Consider not using the sidebar or widget for now. Just make a tag link function that you can place on any template. The links go to a single page that uses a custom template. The custom template queries for posts as I mentioned aboe. Do not reset this query until after the tags link function is run because it needs to get the post list from this query, not the main page query used to get to this page.

    Reply To: Get images based on TAG
     
    #1

Share This Page

Monarch Social Sharing Plugin