• Resolved Mindfill

    (@noahfischer)


    Hello, I’m a little stuck here- trying to figure out how to display the fields of one post in more than one widget–for example- the image gallery in main content section, and text of the same post in a sidebar widget at the same time. This is my first WP site, building a child theme with Genesis framework. I don’t know PHP, but am quite familiar with Drupal and could easily do exactly this in Views filtering content by arguments. I am using the WP Query Wrangler plugin to create queries to put into widgets via shortcode -but it does not provide a lot of functionality for filtering, nothing based on arguments.

    I understand that the solution might be to write in some kind of filter hook, but so far its beyond me. Does anyone know if there’s a plugin that would help? Can anyone offer some advice, point in the right direction for setting up filter hooks that query content based on arguments?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi NoahFischer,

    I made Query Wrangler. You could probably make good use of the contextual tokens.

    [query id=1 args=”p={{post:ID}}”] // place in post body
    [query id=2 args=”p={{post:ID}}”] // place in widget

    The “args” attribute allow you to further filter a query from the shortcode. The tokens {{post::ID}} are contextual. As shown, the arguments will add a filter to the query that will limit it to only show data from the post that is currently being viewed.

    The faq has another example or two of using contextual tokens within the shortcodes.

    https://www.ads-software.com/plugins/query-wrangler/faq/

    Let me know if you run into any problems.

    Thanks,
    Jonathan

    Thread Starter Mindfill

    (@noahfischer)

    Hey Jonathan,

    Thanks for helping, and for making Query Wrangler- I have found it super useful getting up and running on WP. Right away, placing [query id=2 args=”p={{post:ID}}”] in the widget worked- it pulls up content from the same post as I wanted. My next question is, how to control this content with a finer grain ? In Query wrangler, I added the field for post content, but is there a way to separate the text from the image gallery inside the content, as in Drupal you could display the body and images as separate fields?

    Thanks again, Noah

    Hi again,

    There is a problem with the Post Content field that I need to address. In the meantime, add a “Callback” field instead and use “the_content” as the callback. That will be more like what you’re expecting.

    For Images, it really depend son how you’ve added images to a post. If it’s just 1 image per post, then I recommend setting that image as the post’s “Featured Image”, then using the “Featured Image” field in QW.

    But it sounds like you’re saying that you have an image gallery embedded in the posts with shortcodes? Could you explain your setup a little more?

    Thanks,
    Jonathan

    Thread Starter Mindfill

    (@noahfischer)

    Hey Jonathan,

    Ok, tried the callback field with the_content. It seems to do the same thing as the Post Content field, namely display the entire content of the post.

    I have text, a code for the show/hide plugin, and image galleries with multiple images embedded in posts. I add the image galleries using the standard genesis gallery system, through the WYZWYG interface, not shortcodes.

    What I would like to do is- using the contextual filters system you suggest above- display the full text with html formatting in one widget, and only the image gallery of the same post in another widget. So far following your suggestions, I have the complete content of the post replicated in both widgets. Have tried the post excerpt field to display only text, but it seems to strip the html formatting and I don’t know where to control the length of the excerpt.

    Do you think its a question of adding the images to posts in a different way to accomplish this?

    Thanks, Noah

    I think you do want to store your images differently. What are you using for your image gallery? The default [gallery] shortcode?

    Thread Starter Mindfill

    (@noahfischer)

    Yes, I am using the default gallery shortcode. Also have tried adding Nextgen gallery in the post, but that also seemed to embed images into the content field. What I need is images and text divided into separate fields they can be turned on and off with Query Wrangler in different widgets. What image system would you suggest?

    Another thing I tried was making a custom field using Advanced Custom Field plugin displaying just the text in a post, and creating a code in Query Wrangler where I could display it as a widget using your suggestion [query id=2 args=”p={{post:ID}}”] //
    However, I could not get the custom field, or any custom field to display.

    So, there are a few ways.

    If you upload all your images to a post (even if you don’t embed them), they will be “attached” to that post. Then you can use the QW field “Image Attachments” to handle their output.

    Another way would be to use ACF to create an Image field, but unless you have the Pro version, you’ll only be able to add 1 image, which defeats the purpose of a gallery. If you have the Pro version of ACF, you could use an Image Repeater field.

    To get custom fields to show up in QW, you need to make sure your field name/slug does not start with an underscore. QW does not show any custom fields whose name/slug starts with “_”, because those fields are intended to be “silent”.

    Hope that helps. I think the easiest to get setup would be the image attachment route, but sometimes that can be confusing and hard to manage. I’d say give it a shot and see what you think.

    Thanks,
    Jonathan

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Fields of One Post in Different Widgets at same time?’ is closed to new replies.