Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
GRECOROMANGRABASS
May 14, 2020
I've seen wordpress sites that have multiple store locations with a permalink structure that is like "https://gas-station-guru.com/gas-station-finder/tx/dallas/gas-station-name"

Where gas-station-name is a post with info about a gas station in Dallas, TX.

I'm really having a hard time figuring out how to make this work with permalinks, custom post types, and custom taxonomies. I understand I could manually edit the permalink on a per-post setting, but this site has over a thousand locations to edit and I'm running out of time.

I assume the wordpress sites with this kind of link structure are set up like this (please correct me if I'm wrong)

gas-station-finder is the category base

tx is a term of the state taxonomy type
dallas is a term of the city taxonomy type

gas-station-name is just a posttype for a location in dallas, tx.

I feel like i'm missing something in the area of slug and has_front in my CPType / CPTax setup and I'm hoping someone will help me along in the right direction.

(I also need to support sity and state archive pages but I don't think that will be hard using the template hierarchy as a reference unless I have to do some wild rewrite rules.)

Or maybe I don't need two custom taxonomies? Should I just do taxonomy-name/term/term/post-name?

ANY help would be greatly appreciated!

Adbot
ADBOT LOVES YOU

the heat goes wrong
Dec 31, 2005
I´m watching you...
Can't you do it with just hierarchycal categories?

TX category has a child -> dallas category, etc

Thorbeef
Jul 24, 2007

the heat goes wrong posted:

Can't you do it with just hierarchycal categories?

TX category has a child -> dallas category, etc

This is the only way I can think that this can be done, without a heap of coding black magic. You'll need to add each city under its corresponding state category. The permalinks will sort themselves out this way.

Will be a bit of a headache to update all the posts though..

ModeSix
Mar 14, 2009

Apologies in advance for my scattered idea here.

I am trying to run a React app on top of Wordpress but I want to use built in Wordpress authentication rather than an Auth form in my app.

My users need to access the dashboard as normal, but view/edit content through the React frontend.

Is there a way to get the cookie information generated by the Wordpress login to pass through for authentication in my React app for the POST api method?

Basically, auth will happen using the standard Wordpress login form, but I need the auth data generated available to my React app so it can modify posts without having a login flow on the React side of things.

I can't find anything useful when searching as everything I've found is about building a login form and posting to the API for auth.

ModeSix
Mar 14, 2009

Secondary thought on this, since I am running the React app inline within Wordpress... I guess I can just create a php form to handle posting which should be authenticated as long as I run it inside a page-template of sorts?

Or... will the React app already have authority to POST to the API since it's running inline in a Wordpress page?

wearing a lampshade
Mar 6, 2013

p sure you just use nonce

dorkthrone
Nov 11, 2019

Does anyone here use Oxygen Builder? I've been using it for about 8 months now, and have been pretty content with it's performance.

wearing a lampshade
Mar 6, 2013

anybody have any experience auto-generating "posts" with viewable pages (in this case a catalogue of products) from an external REST api? Trying to think of a solution that doesn't involve copying results from the API to the DB while still being able to take advantage of builtin stuff like sitemap generation etc, is it pretty much just down to running it all in a react app w/ routing and a separate product-only sitemap?

EricBauman
Nov 30, 2005

DOLF IS RECHTVAARDIG
This could be a case where post by email, which is natively supported by WP, comes in handy.

Whatever script you have pulling information from the catalog API could email it to your WP email address

worms butthole guy
Jan 29, 2021

by Fluffdaddy
any of you super smart when it comes to mysql? I had to go in on my digitaloceanj test account to change my admin login password and I said:

code:
use wordpress;
which apparently broke my site from loading. I went into WP-config and it's set to load from that database but I still cna't get it to load...any ideas?

e; I fixed it, somehow my servers firewall got reset

worms butthole guy fucked around with this message at 12:12 on Jun 13, 2022

wearing a lampshade
Mar 6, 2013

i have a clients website with 13000 posts, 7000 terms for said posts, a dozen plugins and 30 second page loads for editing posts. edit: should clarify, the loads aren't on the posts themselves, but on pages with lots of ACF fields using data from those posts/tags (relationship fields, term fields, yadda yadda)

a while back, using query monitor found some code in our theme that was taking a good chunk of time to execute, so i changed it and made it use transients etc. seemed to have fixed it for a while.
a couple months later and the slow loads are back, fixed another leak in our stuff but I keep seeing KILLED QUERY(~35000 characters long etc) in WPEngine, but now its from other plugins like ACF and Yoast. Client is also running WPML, and all those associated "WPML for X support" plugins. Can't do anything about that

Object caching speeds it up, but only to these abysmal load speeds - with it disabled, i honestly dont know if the page ever loads.

Common denominator seems to be queries involving get_terms, but I haven't been able to find a solution that addresses our theme and all these plugins.
I don't wanna keep banging my head against a wall - is there anything you folks would recommend trying or do i just need to tell my boss that they need to pay more for a better server or something, because codebase is locked in and I can't do anything about the plugins used.

fuf
Sep 12, 2004

haha
I've inherited a site that uses CF7 for the enquiry form, but for some reason the original developer hard coded their own version of the form into the theme, which I'm pretty sure is meant to submit data to be handled by CF7 on the backend.

The opening form element in the theme's template file looks like:

code:
<form
        action="/"
        class="form js-wedding-booking-form"
        id="323"
        data-label="Wedding form"
    >
where 323 is the ID of a form created in CF7.

At some point after WP updates and CF7 updates this has stopped working, and now submitting the form doesn't do anything.

Obviously a long shot but does anyone have any idea how I could get this working again? Does the CF7 form also have to be included on the page somehow (but hidden?) so that it's present to handle the form submission?

worms butthole guy
Jan 29, 2021

by Fluffdaddy
A class name of js-wedding-form tells me there's some jquery somewhere that operates the form, and it's probably made with a old version of jquery and that's why it broke. Check the functions.php file for any kind of side loaded Javascript file ?

fuf
Sep 12, 2004

haha
Thanks, that's very helpful.

There is indeed an index.js which includes this line:

code:
new Form('js-wedding-booking-form');
and then a Form.js which looks like:
code:
import flatpickr from "flatpickr";

class Form {

    constructor(formClass) {
        this.form = document.querySelector(`.${formClass}`);

        if (!this.form) return;
        this.id = this.form.id;
        this.url = `/wp-json/contact-form-7/v1/contact-forms/${this.id}/feedback`;
        this.date = this.form.querySelector('#date-field');
        this.time = this.form.querySelector('#time-field');

        if (this.form && this.id && this.url) this.setup();
    }

    /**
     * Send form data
     */
    sendData(label) {
        const XHR = new XMLHttpRequest();
        const FD = new FormData(this.form);

        XHR.addEventListener("load", e => this.formSuccess(label));

        XHR.addEventListener("error", e => this.formError());

        XHR.open("POST", this.url);
        XHR.send(FD);
    }

    /**
     * On form error
     */
    formError() {
        alert('Oops! Something went wrong.');
    }

    /**
     * On form success
     */
    formSuccess(label) {
        this.form.classList.add('is-successful');
        this.form.querySelector('button[type="submit"]').disabled = true;
        ga('send', 'event', label, 'submit');
    }

    /**
     * Add form event listener
     */
    formEventListener() {

        this.form.addEventListener("submit", e => {
            e.preventDefault();
            this.sendData(e.target.dataset.label ? e.target.dataset.label : '');
        });

    }

    /**
     * Initiate Time Picker
     */
    initiateTimePicker() {
        flatpickr(this.time, {
            enableTime: true,
            noCalendar: true,
            dateFormat: "H:i",
        });
    }

    /**
     * Initialise Date Picker
     */
    initiateDatePicker() {
        flatpickr(this.date, {});
    }

    /**
     * Setup methods
     */
    setup() {

        if (this.date) this.initiateDatePicker();
        if (this.time) this.initiateTimePicker();

        this.formEventListener();
    }

}

export default Form;
Presumably this is the crucial bit:
code:
 this.url = `/wp-json/contact-form-7/v1/contact-forms/${this.id}/feedback`;
but I have no idea if/where something is wrong.

There are no javascript errors in the dev console when loading the page or submitting the form.

edit: ok looking at the network tab in chrome I can see that the form is being submitted to the CF7 api successfully, and is getting this response back:
code:
{"contact_form_id":323,"status":"spam","message":"There was an error trying to send your message. Please try again later.","posted_data_hash":"","into":"#","invalid_fields":[]}
So it's being marked as spam? CF7 is using reCAPTCHA integration...

e2: disabling reCAPTCHA has fixed it... *shrug*

Thanks again for pointing me in the right direction :)

fuf fucked around with this message at 13:18 on Oct 3, 2022

worms butthole guy
Jan 29, 2021

by Fluffdaddy
what a annoyingly complex way to do a form. seems like the person was bored and wanted to do it manually which I get but......I don't see any outside API calls or anything and you could easily do that form in something like GravityForms lol

also if any WordPress developers are looking for work, I am looking for someone to take over my old clients who are annoying as gently caress small businesses. It pays lovely, probably $35 or $40 a hour and its self employed so it's not consistant but if anyone wants some WordPress work send me a PM and I can put you in touch

kedo
Nov 27, 2007

worms butthole guy posted:

also if any WordPress developers are looking for work, I am looking for someone to take over my old clients who are annoying as gently caress small businesses. It pays lovely, probably $35 or $40 a hour and its self employed so it's not consistant but if anyone wants some WordPress work send me a PM and I can put you in touch

Way to sell it. :P

worms butthole guy
Jan 29, 2021

by Fluffdaddy
rather be honest lol. small business owners are :

1. extremely cheap (we're talking $50 of work will set them off on a long rant)
2. extremely needy

kedo
Nov 27, 2007

Yeah, I have mostly stopped working with small businesses for exactly this reason. I got tired of every invoice being nitpicked and every email subject line saying something along the lines of "URGENT/BUSINESS CRITICAL!!!! my pink text isn't showing up as pink"

worms butthole guy
Jan 29, 2021

by Fluffdaddy
please trigger warning your posts :suicide:

edit: Just last week I had a client from 2 years ago ask me where their site is.....something I did for free back then for them to get my name out and they never moved it off of a free server i setup for them (it wasn't even a live site) so it got deleted. I said "looks like it got deleted" and I got a barrage of "this is business critical we were going for grants with this site!" and then a barrage of text messages saying the same thing

no you're aiming to get a free government handout and I'm still not going to get anything out of this.

:sigh:


yeah i remade it for them :suicide:

i don't know how many times I have to tell these people I don't even work in web dev anymore

edit 2: this is now a vent post


another example from this past week

a client I work with has a few plugins that have expired

e-mails "WHATS WRONG FIX IT!"

"your liscence expired, here are links to renew them"

"WHEN CAN YOU CALL ME TO GET MY CREDIT CARD NUMBER TO DO THIS FOR ME UNPAID"

"uh i just sent you the links to do it, earliest I can go to is next tuesday"

"OK SOUNDS GOOD"

:suicide:

worms butthole guy fucked around with this message at 15:09 on Oct 3, 2022

kedo
Nov 27, 2007

worms butthole guy posted:

yeah i remade it for them :suicide:

You are too nice. My response to this sort of thing is "Sure, I'd be happy to help you with this! Here's an hourly work contract with my rush rate. I estimate this work will take X hours, so the invoice requires a deposit of Y to cover initial expenses. I look forward to helping you with your project!"

The only person in my life who I'll do work for for free is my wife because she's the person who has to listen to me bitch and moan about doing free work (so she pays for it in a way, I guess). No one else gets free work, period.

fuf
Sep 12, 2004

haha

worms butthole guy posted:

what a annoyingly complex way to do a form.

lol I know right.


kedo posted:

Yeah, I have mostly stopped working with small businesses for exactly this reason. I got tired of every invoice being nitpicked and every email subject line saying something along the lines of "URGENT/BUSINESS CRITICAL!!!! my pink text isn't showing up as pink"

Small business clients can be the worst but to be fair I also have A LOT of clients who just dutifully pay my invoice every year and never raise a peep. I NEVER login to their site or do any maintenance work and I just cross my fingers and hope it keeps running. I wouldn't even notice if they broke tbh because I never check them. Feels kind of like a scam sometimes but oh well.

kedo
Nov 27, 2007

Are you contracted to do maintenance work? Because if so and if you're not doing it, then it doesn't just "feel" like a scam. ;)

fuf
Sep 12, 2004

haha
I dunno, there's no real contracts involved so it's all pretty ambiguous. I guess in theory it's a "managed" hosting service, which should include updates and maintenance, but I also don't charge very much (like only $20 a month) so expectations are pretty low.

But yeah I guess I do less than I should. According to WHMCS I host 83 WordPress sites and I reckon it's probably only an hour of work a week on average. And usually that's an hour I can bill for somehow, or it's setting up a new site / email address that I can bill for going forward.

I'm not a WordPress dev anymore, they're all just old clients, with a trickle of new sites that get passed on to me from agencies I used to do work for who don't want to host themselves. I keep thinking it will dry up but it hasn't yet.

fuf
Sep 12, 2004

haha
Another issue caused by the same dev who decided to roll his own contact form design... This time it's an ACF thing.

The error is
code:
[04-Oct-2022 08:29:10 UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in room.php:121
line 121 of room.php is:
code:
 <?php if ( get_sub_field( 'booking_button' )['title'] ) { ?>
Apparently this was just a warning in php7 but is now a fatal error in php8.

Any suggestions on how to fix greatly appreciated...

kedo
Nov 27, 2007

fuf posted:

Another issue caused by the same dev who decided to roll his own contact form design... This time it's an ACF thing.

The error is
code:
[04-Oct-2022 08:29:10 UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in room.php:121
line 121 of room.php is:
code:
 <?php if ( get_sub_field( 'booking_button' )['title'] ) { ?>
Apparently this was just a warning in php7 but is now a fatal error in php8.

Any suggestions on how to fix greatly appreciated...

It looks like that line expects 'booking_button' to return an array, but instead it's returning a string. I'd check to see what it's actually returning and then adjust your code accordingly.

EricBauman
Nov 30, 2005

DOLF IS RECHTVAARDIG
I'm doing wordpress stuff for the first time in a while, and the space has just gotten super frustrating. I think Gutenberg may have been a move that will do wp more harm than good.

It is almost impossible to find a modern looking theme to build a home page (landing page that includes a widget with some latest posts, nothing special) that doesn't come with its own inferior built in editor that forces you to use it rather than normal wp features. Great, you've barred me from editing the footer outside of your editor, I can't use widgets anymore, and the normal customizer is gone or completely overhauled. Oh, and if you do create a home page, it'll be gone if you switch to a different theme, because guess what, we don't actually use pages and store everything in the theme.

I think everyone now wants to be the next Elementor or Divi, and it's ruining wp. There's no way to filter out these themes or see before you activate them that they have this garbage.

Don't mind me, I'm just voicing my frustrating before I go looking for themes that haven't been updated since 2019 so I don't have to deal with this bullshit anymore

kedo
Nov 27, 2007

Yeah, the pre-made theme market is a poo poo show these days because everyone is trying to compete with the likes of Squarespace and Wix, so if your theme doesn't come with a site builder built in, it is bEhInD tHe TiMeS. Elementor isn't terrible, but it isn't great either. I had to make a site with it once (due to a client's request) and it was an absolutely massive pain in the rear end. I won't touch Divi.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Anytime I have to deal with WordPress now I just use GeneratePress

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer
I was going to reply that I'm happy I don't have to work with pagebuilders, but I just had a meeting at work and was told that I'm going to have to use them for smaller clients. Those clients want to know they can go in and make changes on their own, replace images, whatever. My previous method was to force Wordpress to load (and sanitize) HTML documents so that I wouldn't have to work with custom HTML blocks and could use VS Code. Sort of a pseudo-headless solution. Wordpress was only used for creating new posts/pages and meta information stuff.

The old developer here used to use Divi, but I'm going to see if plain ol' Wordpress Gutenberg blocks might be good enough. That way I could still style them with CSS, and the clients can still go in and make minor edits to text, images, etc. without having to know HTML.

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer
Update: This sucks so much. I'm going to see if I can get away with using Wordpress's default Gutenberg blocks in a custom theme that lets me define their styling in CSS. Even if I have to give them custom classes. Honestly the "Cover" and "Media + Text" blocks cover 90% of what goes on the average page, plus the straight-up image, text, list, etc. blocks. I hate that I can't strip out all the hideous un-semantic HTML and default class output, but I need to pick my battles. They said I'd be able to do my usual custom work on larger sites, but for smaller clients they said the reasoning is they're competing with Wix, Squarespace, etc. so they need to be able to tell a client "Yeah, you can go in and replace text and images no problem!" even if they never do it.

I could create my own plugin that contains replicas of the default Wordpress blocks but with my own classes and semantic HTML tags. Gutenberg development seems to have gotten a little better since it started.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Do yourself a favor and learn HubSpot sp you can leave WordPress farrrrrr behind

ajkalan
Aug 17, 2011

Question from a novice. What is the purpose behind spam bots visiting favicon.ico? I've cut down on most of the wannabe malicious traffic to my site after redirecting the default WordPress login page elsewhere, but now I'm noticing more visits to favicon. I don't have a favicon set up and am not actually concerned about them doing anything, it's more that I'm confused about why they would go there at all. What dumb exploit are they going for?

fisting by many
Dec 25, 2009



ajkalan posted:

Question from a novice. What is the purpose behind spam bots visiting favicon.ico? I've cut down on most of the wannabe malicious traffic to my site after redirecting the default WordPress login page elsewhere, but now I'm noticing more visits to favicon. I don't have a favicon set up and am not actually concerned about them doing anything, it's more that I'm confused about why they would go there at all. What dumb exploit are they going for?

Are you sure it's spam bots? I think browsers will look for a favicon.ico by default, even before loading the page. Idea is that it'd be nice to show the user an icon early without having to wait for the page to load to see where the icon is and then go fetch that icon. Instead browsers will just guess there is something at /favicon.ico and if not, no harm done.

ajkalan
Aug 17, 2011

fisting by many posted:

Are you sure it's spam bots? I think browsers will look for a favicon.ico by default, even before loading the page. Idea is that it'd be nice to show the user an icon early without having to wait for the page to load to see where the icon is and then go fetch that icon. Instead browsers will just guess there is something at /favicon.ico and if not, no harm done.

I have no idea honestly, just making an assumption. In which case it's good to know that the lowest effort mitigation stopped the unwanted traffic.

zmcnulty
Jul 26, 2003

My contact form seems to have died sometime around August 2nd. I only noticed about a week ago. It collects data but no longer emails me the form results. So I have to go into the dashboard -> Feedback -> Form Responses to see what I received. Luckily I didn't miss anything hugely important, but it is how I receive most inquiries via my site.

Does this sound like a WP issue or something else? I'm running 6.0. Because it wasn't working, I tried converting the page from old-school block editor to Gutenberg, and change my email, but appears to have done nothing. If I could somehow identify what happened around August 2nd, like if I did a WP upgrade or plugin upgrade or something, it might help. Does WP keep a log like that somewhere? I may or may not have removed some plugin, but in that case, the form wouldn't work at all, correct?

If it matters, I still get other emails from WP, like the email subscription confirmation.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
What gorn plugin are you using

zmcnulty
Jul 26, 2003

Jetpack, I guess. When I originally built the page it was the jetpack form inserted via classic editor.

https://jetpack.com/support/contact-form-classic-editor/

When I click Edit Page, it's showing in Gutenberg using the Classic block, including the form.
If I Convert to Blocks using Gutenberg it shows the form using the shortcode block.

code:
[contact-form to="mydumb@email.com" subject="website inquiry"][contact-field label="Name" type="name" required="1"][contact-field label="Email" type="email" required="1"][contact-field label="Inquiry Type" type="select" required="1" options="Personal,Business,Media,&#20491;&#20154;,&#20225;&#26989;&#12539;&#22243;&#20307;,&#12513;&#12487;&#12451;&#12450;"][contact-field label="Message" type="textarea" required="1"][/contact-form]
I suppose I could try blowing away all of the old page content and just use bonafide Gutenberg blocks rather than classic/shortcode anything.

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer
The default Gutenberg blocks are pretty good. I ran into an issue where the Gallery default block would be perfect for a portfolio gallery I needed for a site... if only it let you link thumbnails to other media and assign them a category. You can extend the default blocks but it's kind of a hassle and making a new Gallery block gives me a headache. I didn't want to spend hours figuring it out, so I'm going to use a custom post type and archive page instead.

I wish I was using Next.js but I'm stuck in Wordpress world.

wearing a lampshade
Mar 6, 2013

gutenberg's getting better but its still full of weird structural decisions that they'll definitely be paying for in the future.

im pretty sure its still a bug in core, but i found out that if you use theme.json / the full site editor stuff you can't also use php templates at all. it won't render block styles, period. so no best of both worlds w/ super customized pages and generic gutenberg templates.

Adbot
ADBOT LOVES YOU

kedo
Nov 27, 2007

zmcnulty posted:

My contact form seems to have died sometime around August 2nd. I only noticed about a week ago. It collects data but no longer emails me the form results. So I have to go into the dashboard -> Feedback -> Form Responses to see what I received. Luckily I didn't miss anything hugely important, but it is how I receive most inquiries via my site.

Does this sound like a WP issue or something else? I'm running 6.0. Because it wasn't working, I tried converting the page from old-school block editor to Gutenberg, and change my email, but appears to have done nothing. If I could somehow identify what happened around August 2nd, like if I did a WP upgrade or plugin upgrade or something, it might help. Does WP keep a log like that somewhere? I may or may not have removed some plugin, but in that case, the form wouldn't work at all, correct?

If it matters, I still get other emails from WP, like the email subscription confirmation.

WordPress is notoriously terrible at sending email. Try WP Mail SMTP paired with your SMTP provider of choice and just use someone else who specializes in email instead. This is the silver bullet for 99.99% of WP email problems.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply