Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question. The current MLA version does not have a parent_category datasource, but you can create one with a small amount of PHP code that uses the hooks built in to the [mla_gallery] shortcode or the metadata mapping logic. I can give you more specific help if I know a bit more about your application.

    1. Do you need the parent_category value in an [mla_gallery] shortcode or in a metadata mapping rule?
    2. If a parent has more than one term assigned to it, how do you decide which term is “primary”?
    3. Is some PHP code in your theme’s functions.php file or a small custom plugin acceptable?

    I am traveling for a few more days, but if you can answer the above I can work on this after my return home. Thanks for your patience and for your interest in the plugin.

    Plugin Author David Lingren

    (@dglingren)

    Here is an earlier topic that is similar, but more complex, than the application you have in mind. I can work with you to adapt the approach to your specific needs.

    Generic shortcode for page generated from thumbnail link

    Thread Starter Levy

    (@andrelevy)

    Thanks for the thoughful reply, David. Sorry for my belated response. My answers:

    1. Metadata mapping, I reckon. Each post in my site is a quote (not all, but let’s just say), and the featured image is a photo of the author. I’ve been using parent_title to bulk fill out the title and the alt of the image, but ideally what I’d like to put as the alt is the author, which is the category of the post.

    2. I don’t assign posts to more than one category on this site, but the distinction of a primary category for each post is now standard in WP. That’s true for categories, not tags.

    3. Sure. Not ideal, but I’ll beta test it for you, if you’d like to later include it in the main code.

    I had a look at the other thread, but it seems to refer to alternate uses of variables already defined in the main code, no? (e.g. description, caption, page_title, etc)

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the additional information, and for taking the time to look through the related topic I mentioned.

    After pondering your comments and application requirements I decided that the best approach required some changes to MLA itself. I have uploaded a new MLA Development Version dated 20160604 that implements four new filters (hooks) that let you define “custom data sources”. I’ve been thinking about something like this for some time and your application gives me a great example of how to use it; thank you!

    The new Development Version also contains an example plugin that provides the parent category values your application requires. When you have installed and activated the /examples/mla-substitution-parameter-hooks-example.php.txt example plugin you can populate your ALT Text values with a mapping rule:

    1. Navigate to the Settings/Media Library Assistant IPTC/EXIF tab.
    2. Scroll down to the ALT Text line of the Standard Field Mapping section.
    3. Enter template:[+parent_terms:category,single+] in the text box under the EXIF/Template Value heading.
    4. Set the Priority dropdown control to EXIF and the Existing Text dropdown to Replace.
    5. Scroll to the bottom of the screen and click “Save Changes” to record your settings.

    Once that’s done you can use the Map All Attachments, Standard Fields Now button to go back and set the ALT Text field for your existing items, if that is appropriate. You can use the Media/Assistant Bulk Edit area or the Media/Edit Media screen to make more selective replacements. Look for the Map IPTC/EXIF Metadata button on either of those screens.

    To get the Development Version, follow the instructions in this earlier topic:

    Shortcode not working in (special) widget

    It would be great if you can install the Development Version, try the example and let me know how it works for you. The “Field-level substitution parameter filters (Hooks)” of the Settings/Media Library Assistant Documentation tab has more information on the new fiters and how to install the example plugin. Of course, if any other problems emerge I want to know about them as well.

    If you would rather get the example plugin by email, send you contact information and I will reply with the code. You can give me your contact information using the Contact Us page at the FTJ web site:

    Fair Trade Judaica/Contact Us

    Do not post your e-mail address in the forum; personal details in a public forum violates WordPress guidelines. If you have trouble accessing the FTJ site, post a note here with your country of origin and I can temporarily unblock it.

    You wrote “the distinction of a primary category for each post is now standard in WP. That’s true for categories, not tags.” My search of the WordPress Codex failed to return any information on “primary category”, but a Google search turned up these items:

    How can I select a primary category?

    WordPress Tip: Specify a Primary Category using Advanced Custom Fields

    Yoast SEO 3.1: Improved snippet editor and primary category

    The new Make Primary category function in Yoast SEO

    If you have any further details on a WordPress “primary category”, let me know. In the interim I added the ,single format option to the mapping rule to pick the first category assigned to the parent just in case there are multiples. You could remove it to get a comma-delimited list of all categories when there are multiple assigned terms.

    Finally, I see you have discovered the shortcomings of the WordPress parent/child tradition:

    How do I extract the id from inserted_in and featured_in?

    As you’ve discovered, WordPress is lax in attaching items to a post/page when it is inserted or used as a Featured Image. You may also have discovered that a single item can be inserted in or be the Featured Image of more than one post/page. I will address those issues when I work on a response to your other topic.

    Thread Starter Levy

    (@andrelevy)

    Thanks for the ever so kind response, David.

    I followed your instructions – installed the dev version and all – but it didn’t work.

    Here is the config and the outcome: https://imgur.com/a/WJP62

    But I’m glad I learned how to map the image title to the parent title by default ??

    Your plugin is a powerhorse!

    P.S. Oh, I thought the primary category was std WP, but it must be a Yoast thing. Is that what the problem is?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for giving it a try and posting the results.

    Did you also go through the process of installing and activating the example plugin? The [+parent_terms:category,single+] literal would show up if the example plugin wasn’t running. Also, the literal would appear for any item not attached to a parent. To suppress that you can add parentheses areound the value as follows:

    template:([+parent_terms:category,single+])

    P.S. The Yoast “primary category” doesn’t affect the example plugin or the results.

    Thread Starter Levy

    (@andrelevy)

    Aha, ok, I wasn’t sure what you meant by “When you have installed and activated the /examples/mla-substitution-parameter-hooks-example.php.txt example plugin ” – I thought this would automatically install with the rest of the main code, but now I followed your instructions in the documentation as below and have it installed.

    And, yet, no can do: https://imgur.com/a/Rg7CQ

    I tried both with and without parenthesis. With, nothing happens, and without it pastes in the literal parameter code.

    An example of using the hooks from a simple, stand-alone plugin can be found here: mla-substitution-parameter-hooks-example.php.txt. To run the example:

    1. Remove the “.txt” extension and save the “mla-substitution-parameter-hooks-example.php” file in your plugins directory. You can give the plugin and its file any (unique) name you like.

    2. Go to the Plugins/Installed Plugins screen and activate the “MLA Substitution Parameter Hooks Example” plugin.

    3. Create a new [mla_gallery] shortcode, markup template or mapping rule that uses terms from an item’s parent post/page.

    4. Run the shortcode or mapping rule to see the plugin’s data put to use.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the additional results. I regret the trouble you are having getting the example plugin to work.

    It will be more productive to debug the problem by email. Please use the FTJ “Contact Us” form to send me your address. I will work with you offline and post a summary here when we’ve reached a conclusion. Thanks for your patience and your understanding.

    Thread Starter Levy

    (@andrelevy)

    Ok. Done.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for working with me offline to complete the resolution of the problem. I have released MLA version 2.30, which contains the new example plugin.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the new version. Thanks for your help with this new MLA feature.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Parent category tag’ is closed to new replies.