Forum Replies Created

Viewing 15 replies - 1 through 15 (of 140 total)
  • Thread Starter OsakaWebbie

    (@osakawebbie)

    Haha, “tagless posts” sounds like tagless T-shirts (or perhaps underwear, since this nomenclature seems to be underWARE). Anyway, thanks for the clue. I suspected the name might be different, but I didn’t know how to check other than what tag archives use in the URL, and my search attempts failed to reveal anything other than “tag”. (Now that I actually search on “post_tag”, of course all kinds of references show up. Hindsight is 20/20.)

    Yeah, the underscore vs. hyphen thing has been driving me nuts for years, especially when writing CSS to target classes. I chalked it up to differences between theme/plugin developers and WordPress, but apparently there’s a variety inside WP core as well. As you said, WP has been developed gradually over many years by thousands of people, and trying to maintain backwards compatibility would make it challenging to clean up the inconsistencies.

    Thanks for all your help!

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Wow, I didn’t know about that operator – that works perfectly! And no need to get a collection of all the terms in order to exclude them in the query.

    I added checks to limit it to both a specified post type and a specified (presumably current) user. The chance of anyone else working on the site at the same time as me is near zero (I do 99% of the work), but it’s still good practice. Here’s my final

    function posts_with_empty_tax($query) {
    	/*** SET THESE THINGS BEFORE USING ***/
        //return;  // comment this out to use the function
        $posttype_to_check = 'post';  // set to desired post type: post or guideline
        $tax_to_check = 'issue';  // set to desired taxonomy: issue, article_author, guideline_topic (maybe tag???)
    	$user_checking = 'redacted'; // set to yourself
    	
        if (!is_admin()) return;
    	if ($query->get('post_type') != $posttype_to_check) return;
    	$user = wp_get_current_user();
        if ($user->user_login != $user_checking) return;
        $tax_query = array(array(
            'taxonomy' => $tax_to_check,
            'operator' => 'NOT EXISTS',
        ));
        $query->set( 'tax_query', $tax_query );	
    }
    add_action( 'pre_get_posts', 'posts_with_empty_tax' );

    I have one more question: Changing $tax_to_check to other custom taxonomies works, but I can’t get tag to work – I get no posts even though I know there are lots of posts with no tags. (I suspect category would act the same way if I had any posts without one, but it’s a required field in my setup so I can’t test.)

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Thanks – you gave me a lot of clues.

    FYI: Plugin framework is not my worry – I already have a site-specific plugin where I moved some stuff out of functions.php that isn’t theme-dependent. So I can add whatever I want there.

    The other main challenge with plugin development is determining what hooks you should use. … TBH it’s a tangled mess.

    Indeed.

    I found someone who claimed on stackexchange to have made a taxonomy column sortable, so I tried his code (even though his answer only got one up-vote, so I didn’t hold my breath). It does make the column header clickable, and the posts with a term do appear to sort, but the posts with no terms don’t end up together. So that might be handy sometime, but it doesn’t fulfill my current wish.

    So I embarked on the journey to make an action for pre_get_posts. After a lot of research about parameters and syntax, this is what I came up with, but so far it doesn’t work – no posts are returned at all.

    function posts_with_empty_tax($query) {
        //return;  // comment this out to use this function
        $tax_to_check = 'issue';  // set this to desired taxonomy
        if (!is_admin() ) return;
        $all_terms = get_terms(['taxonomy'=>$tax_to_check, 'fields'=>'ids']);
        $tax_query = array(array(
            'taxonomy' => $tax_to_check,
            'field' => 'term_id',
            'terms' => $all_terms,
            'operator' => 'NOT IN',
        ));
        $query->set( 'tax_query', $tax_query );	
    }
    add_action( 'pre_get_posts', 'posts_with_empty_tax' );

    Can you see an obvious mistake somewhere?

    Thread Starter OsakaWebbie

    (@osakawebbie)

    In my case, each post with no terms needs human research and decisions, so batch UPDATE is not applicable.

    Even the page template that you call utilitarian would be new to me, so first I’d have to study how to make one and then write whatever code needs to surround the WP_Query, and I wouldn’t know how extensive that would be until I start doing it. Apparently you already know that a page template would be easier to write than a little plugin to add a filter to the Posts list on the admin side (or to allow sorting the Posts list by taxonomy columns, which I’m surprised WP doesn’t already do and that no one has already written a plugin to add it) – I would have no idea which is easier, since both are new territory for me. A plugin for the admin side has three advantages: (1) it’s exactly where it would be most handy, allowing Quick Edit, (2) it would be theme-independent, so it could be used on other sites, (3) it’s not on the front end where it might get indexed by SE bots. Do you have a feel for how hard it might be to write such a plugin? I definitely speak PHP, but mostly outside of WP, so when I write code in WP I spend 95% of my time looking up structure and functions and such, not writing.

    • This reply was modified 4 days, 10 hours ago by OsakaWebbie.
    Thread Starter OsakaWebbie

    (@osakawebbie)

    Thanks. It’s not that I don’t know PHP, but building something with WP_Query requires some sort of infrastructure (a plugin or a theme template or some other way to run it and display the results), which is not my strength and likely a lot of work just for an occasional check. The infrastructure would take me a lot longer to figure out than the query itself.

    After posting my question, I kept exploring the database structure and eventually wrote this query, which is basically the same sort of approach as yours but in manual SQL style instead of WP style:

    SELECT ID,post_title FROM wpstg0_posts p WHERE post_type='post' AND post_status='publish' AND ID NOT IN (SELECT object_id FROM wpstg0_term_relationships tr INNER JOIN wpstg0_term_taxonomy tt ON tr.term_taxonomy_id=tt.term_taxonomy_id AND tt.taxonomy='issue')

    Of course I’ll have to then search within WP for each of the results using its title, but that would probably be faster (for me anyway) than building a way to call WP_Query – ideally a filter of the Posts list on the admin side, so I can use Quick Edit. But if that’s easier than I’m imagining, I’m all ears.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Yeah, that might work. But the second replacement (to remove </span>) in isolation would be risky, so doing them in one statement instead of two would be a lot safer. I wish I was a whiz at regular expressions – anyone want to help with how to use MySQL’s flavor of regex to do this?

    It seems that a “Clear all inline styling” command in Gutenberg would be helpful for more than just this situation. (Perhaps it would be most broadly useful at the block level, like on the same menu where Edit as HTML is, or on the Block tab in the right pane.) I’m really surprised it doesn’t already exist.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    For anyone who comes along later wanting the CSS for this, here is what I needed to do:

    #pen_top section#media_image-2 {
      margin-top: 0 !important;
    }
    #pen_top .pen_container {
      min-width: 100% !important;
    }

    It’s possible that the ID in the first one, “media_image-2”, might be different in the case of others sites – I don’t know.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    No, I’m not running Classic Widgets, just Widget Options that you originally suggested. Its Pages Visibility module (and probably all the other modules) only works if the Classic Widgets Screen module is not disabled. In other words, apparently Widgets Options is currently only compatible with the pre-5.8 widget editor.

    Anyway, indeed, setting the Color Scheme to “Transparent Background” worked. I assumed it would leave the frame’s space there (which would have looked odd), but it didn’t – that’s good. I haven’t decided which way I prefer it, but it’s not my site (I’m just helping with design), so I’ll ask the owner whether he likes the bordered look or wants a classic “hero” going all the way to the edges.

    FYI, there is no element with class of “widget” that I can find. Here is the markup at the moment (with Color Scheme=”Transparent Background”):

    <aside id="pen_top" class="sidebar clearfix widget-area pen_animate_on_scroll pen_custom_animation_slideInDown animate__animated animate__slideInDown" role="complementary" aria-label="Top" style="visibility: visible;">
        <div class="pen_container">
            <section id="media_image-2" class="pen_widget_transparent pen_animate_on_scroll pen_custom_animation_fadeIn widget clearfix widget_media_image animate__animated animate__fadeIn" style="visibility: visible;">
                <img src="https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?fit=2000%2C1199&ssl=1" class="image wp-image-36  attachment-full size-full" alt="Boy in class in Myanmar" loading="lazy" style="max-width: 100%; height: auto;" srcset="https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?w=2000&ssl=1 2000w, https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?resize=300%2C180&ssl=1 300w, https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?resize=768%2C460&ssl=1 768w, https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?resize=1024%2C614&ssl=1 1024w, https://i2.wp.com/deafministriesinternational.com/wp-content/uploads/2019/08/cropped-IMG_0741-1-4.jpg?w=1880&ssl=1 1880w" sizes="(max-width: 2000px) 100vw, 2000px" width="2000" height="1199">
            </section>
        </div>
    </aside>

    The section#media_image-2 element has a top margin of 16px, but nothing has any other margins or padding. But I really appreciate the suggested CSS – even though that class would have to be changed, it saves me some work figuring out what attributes and values to use.

    Not only is your theme awesome, your support is also outstanding!

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Perfect – thanks! I would have never thought of that as a “menu” related setting.

    OsakaWebbie

    (@osakawebbie)

    I added another image to https://imgur.com/a/awfci7j, showing my two best efforts at getting what I want. The top one was made in the new block widget editor (I’m running Widget Options, which uses the Classic Widget Editor, but I temporarily disabled that to do this). Since the block editor doesn’t have widget titles at all, I had to add a heading block and wrap it together with the WPForms block by putting them in a group. Then I re-enabled Classic Widget Editor, and then the widget is categorized as a “Block” with the HTML contents of the block available for manual editing – this is the code showing the top widget in the screenshot:

    <!-- wp:group -->
    <div class="wp-block-group"><!-- wp:heading -->
    <h3>Subscribe by email</h3>
    <!-- /wp:heading -->
    
    <!-- wp:wpforms/form-selector {"formId":"626","displayTitle":false,"displayDesc":true} /--></div>
    <!-- /wp:group -->

    But the heading is then not styled as the title of the widget but as part of the widget innards.

    The bottom widget in the screenshot is the fragile current state of a WPForms widget created in the Classic Widget Editor, with a widget title, form description, but no form name.

    OsakaWebbie

    (@osakawebbie)

    Your screenshot is from the block-style widget editor – the icon on the left is the “legacy widget”, which can then select the original WPForms widget within it. The icon on the right is the new block-style WPForms widget, which doesn’t even have the checkboxes we are talking about. I am running the Widget Options plugin (because of its visibility options), which is only compatible with the Classic Widget Editor, so it has a module to revert the editor type. In the Classic Widget Editor, there is only one WPForms widget, of course – the “legacy” type. It has a widget title field (the same as all other widgets), a pulldown to select the form, and checkboxes to control showing of the form name and description – that’s what @weehorse and I are talking about. See screenshot here: https://imgur.com/a/awfci7j

    However, due to some quirk of switching back and forth between the Classic and Block editors to test things, I have gotten it to sorta work if I’m careful. I’m not sure what happened, but right now I have what I want: a widget title (because its style matches other widgets), form description, but no form name. Now when I go back to check the widget, both checkboxes are checked again (the bug we’re talking about), but as long as I don’t save, perhaps it will be okay.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Okay, I got it to work eventually, but the Widget Options plugin’s “Pages Visibility” control is only available when also using “Classic Widgets Screen”, and in that mode, it took me awhile to figure out how to make the photo full width. I initially felt I had to disable “Classic Widgets Screen”, make an image block widget, re-enable “Classic Widgets Screen”, and set the visibility. But eventually I figured out where to set the size of a legacy Image widget, so that’s what I’m using now. I like the new block-based widget editor (I can’t believe I’m saying that, because I hate the Gutenberg editor for posts/pages because there are so many things I can’t do that were simple in the old editor), but I guess it’s incompatible with that plugin’s ‘Pages Visibility” module for now.

    My original intent was to have the image full-width like the menu bar and touching it, not encased in a widget frame with a thick padding and margins. But this might be okay.

    FYI: Sometimes there is extra space between the menu bar and the Top widget area, at least at first (it seems that sometimes after fiddling with the page a bit, the gap will go away – I’m not sure why, because one of the actions that makes it get well is opening the inspector!). It seems to depend on the width of the window, and possibly on the browser (it definitely happens in Firefox under certain conditions, but I couldn’t get it to happen in Chrome in a few short tests). Here is a screenshot: https://imgur.com/a/TnZNhAb This might be challenging to troubleshoot, but I thought I’d just let you know.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    A few hours ago I tried something similar but couldn’t work it out. The site is already running Jetpack (although I’m wondering if it’s necessary – someone else built the site and I’m revamping it, and it’s hard to tell what existing plugins are actually used), which provides a “Visibility” option on widgets. So I created an image block widget and experimented with where to put it, figuring out that, as you said, “Top” is the right place. But the Visibility button wasn’t there – apparently it’s only available for legacy widgets, and there isn’t an “image” in the legacy widget choices. As I said, I try to keep plugins to a minimum, but I’ve used Widget Options before on other sites, and it seems solid – I’ll try your suggestion.

    Perhaps you could add this to feature requests for your theme. I can imagine two ways to approach it, depending on what else you want to accomplish and how easy/hard it is to implement:

    • A specific “hero image” feature (in the Front Page section of the customizer). I guess this would have the advantage of being a feature you could add to your marketing.
    • As you have Front Page -> Sidebars, if you add that same Sidebars section to other types of views (List View, Full Content View, and Page), I could hide Top in all those other types, and other people might find other uses for hiding widget areas in various layouts.

    By the way, I love your theme! I found it because for this site I needed a theme whose list view would render feature images in tall, not wide, shape (because they are portraits of people). But I’ll remember your theme for other sites, because it has tons of options, tons of widget areas, and a pleasing appearance. I wish I could disable the “reminders” about the Pen plugin (the top of every admin page, the bottom of the editor page, etc., and clicking X doesn’t keep it away). But I know you’re trying to promote your products, so it’s a minor thing. Great job!

    OsakaWebbie

    (@osakawebbie)

    Addendum: I used custom CSS to hide it:
    .footer-widget-1 .wpforms-title, .sidebar .wpforms-title { display:none; }
    So you’ll need to look at the HTML to see the evidence of the bug.

    I look forward to updates about it.

    I’m having the same problem. In my case the site is https://deafministriesinternational.com, and the widget is used both in the footer for all pages and in the sidebar when single posts are viewed. FYI, it’s not just the form name; if a description exists, it will show also without its checkbox being checked.

Viewing 15 replies - 1 through 15 (of 140 total)