Leland Fiegel
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Set post category limit“so want to set only 2 categories.”
This leads to questions:
– Should this requirement be enforced in the WP backend?
– What about posts already published with more than 2 categories?
– Are you only concerned with limiting the *display* of categories in just the component you screenshotted?
– If so, how do you want to determine which categories get thrown out if there are more than 2? Alphabetical order? Something else?
If so, the posts would still display in the category archives in all categories assigned, even if some of them are hidden in the screenshotted component.
“also I want separate categories”
This sounds like a markup/styling question. What’s the code used to output what’s currently there? Just need to separate each category into its own element.Forum: Developing with WordPress
In reply to: file_get_contents() in wp templateIf the files are on the same server, it seems technically okay to use regular ol’ PHP functions to help out. Have you tried this yet? It seems like you were on the right track from your initial post.
One thing worth considering is using an escaping function like esc_html just to make sure any potentially dangerous HTML is stripped out. If the expected output is just a simple string of text, it shouldn’t cause a problem.
Can you go into more detail on your use case? How are these .txt files modified, and what is their purpose? Judging from your is_category code snippet above, are you just trying to display some text associated with a category?
If so, there might be a different approach worth considering. Maybe you can use get_category to dynamically retrieve text and avoid the hardcoding of individual category IDs.Forum: Developing with WordPress
In reply to: 2 websites in same wordpressThere is multisite, as others have mentioned.
Thinking of it like a “network” makes it easier to understand. If the site is another travel blog you want to be “networked” with the original travel blog, or you plan on making more travel blogs within the same network, …multisite network starts to make a lot of sense.
Although for technical reasons, as long as they share a lot of plugins…that could be considered enough relation for multisite to make sense. Instead of updating the same plugins across multiple separate sites, you just need to update the plugins on one multsite instance. It can make maintenance more straightforward.If they’re completely unrelated sites, I’d keep them as separate standalone WordPress installs. Plenty of WordPress hosting services let you keep multiple separate installs under the same account / server.
Forum: Developing with WordPress
In reply to: REST vs Ajax for gallery?Not sure I’m following.
Ajax would be useful for fetching new images dynamically that weren’t in the initial page load. You can add a custom endpoint to the REST API and then use Ajax (these days, the Fetch API) to interact with it from the client-side. So if this is what you’re trying to do, it’s not really a REST versus Ajax situation. They work together.
Is that what you’re trying to do? Or once the page loads, the images that are on the page don’t change?
If the latter, it sounds like you might just need to refactor your existing code.Could share the code you’re working with?
Forum: Everything else WordPress
In reply to: Moving some content from one site to another new domainIf you don’t mind doing it manually, copying/pasting 20 articles might be manageable.
Something to consider for larger migrations is bulk-editing the ones you want to migrate away to add a temporary category like “Migration A” and then using the WordPress Export tool, filtered by the category.
That should make it easier to bulk delete them on the origin site. Then, you can delete just the category on the receiving site.
Always a good idea to practice tasks like this on staging environments to make sure it all works as expected.
“map out old URLS to new ones for the content batch”
Yes, sounds right for reference on the next step.
“implement 301’s on my old site to new for each article URL. switch over any internal links as well on new site.”
This sounds right. This can be done with a WordPress plugin like Redirection. There are other ways of redirecting outside of WordPress like with .htaccess or with your DNS provider.
“Also is GSC change of address even necessary or just best practice?”
I would say it’s not necessary because the 301 directive instructs everyone (and not just one search engine) “hey, this URL is permanently here now.”
I don’t know much about GSC to say if it’s a best practice or not. I guess it can’t hurt although Google should get the hint eventually the next time it crawls your site and notices the 301 redirects.Forum: Developing with WordPress
In reply to: displaying a custom field value in the postI think there may be a misunderstanding over how to use get_post_meta.
The “key” is just a simple string used to reference something set in the built-in WordPress Custom Fields interface under “Name” (as opposed to “Value”).
Let’s say the key/Name is “name” and the value is “Leland” …it would be displayed on the frontend with the following PHP code placed within The Loop:<?php echo get_post_meta( get_the_ID(), 'name', true ); ?>
And that code can be in a child theme to protect your customizations from parent theme updates.
Does this help?- This reply was modified 1 year, 3 months ago by Leland Fiegel.
It’s blank because there is white text on a white background. If you press “ctrl + a” to select all (“apple + a” on a Mac) you’ll see the text revealed. Here is a screenshot.
This appears to be a theme feature. The problem arising on the downgrading/upgrading of WordPress was likely just a coincidence or a minor side effect. The theme author might have a better idea as to what’s going on.
At this point, it depends on how you want to proceed. Do you want to get rid of the top bar entirely? Or change the text color from white to black?We can help with Custom CSS although the white color is currently set with inline CSS, so a no-code customization option might be best to use here.
Forum: Fixing WordPress
In reply to: Admin Invite E-mail Not ReceivedAre any emails received from the website? For example, lost password requests will send an email as well.
You might be having an email deliverability issue. This can be solved by using a third-party SMTP service, many of which have free tiers. And then a WordPress plugin that integrates with the SMTP service.Forum: Plugins
In reply to: [Membership Plugin - Restrict Content] Restricted Content Message ProblemYou could consider simply typing the message out in the code, like in my first example. Saves a trip to the database, especially if the message is not going to ever change.
As for another function to dynamically retrieve the restricted content message, check out the rcp_get_restricted_content_message function. It’s in the core/includes/misc-functions.php file if you want to read it in full.
It’s not wrong to not use it. It’s all about how exactly you want your site to behave.
Since it sounds like you do want to dynamically pull the message, the PHP implementation would be something like this:
<?php if ( rcp_user_has_paid_membership() ) : ?> <p>Content inside here would only be only visible to active paid subscribers.</p> <?php else : ?> <?php echo rcp_get_restricted_content_message(); ?> <?php endif; ?>
Functions are generally supposed to be single-purpose. So in this case, you’d just be using two functions: one to determine if the user has a paid membership, and one to display the restricted content message.
Forum: Plugins
In reply to: [Membership Plugin - Restrict Content] Restricted Content Message ProblemInvoking the rcp_user_has_paid_membership function does not do anything other than return a boolean value: true or false.
If true, then execution within the conditional block continues. That’s when the “Content inside here would only be visible […]” message displays.
In other words, the custom message was not displaying because the code as originally written did not include instructions for that particular task.
Forum: Plugins
In reply to: [Membership Plugin - Restrict Content] Restricted Content Message ProblemYou could use else. For example, something like this:
<?php if ( rcp_user_has_paid_membership() ) : ?> <p>Content inside here would only be visible to active paid and active free subscribers.</p> <?php else : ?> <p>Content inside here would display if the above condition is not met.</p> <?php endif; ?>
Also, reading the sentence about “active paid and active free subscribers” are you sure you didn’t mean to use the rcp_user_has_active_membership function instead of rcp_user_has_paid_membership?
The rcp_user_has_paid_membership check would exclude active free subscribers.
Forum: Plugins
In reply to: [The Events Calendar] How to target a single event with an if statementHi there,
is_singular is the correct function to use to check if the query is for a single post of any post type.
To narrow it down to our event post type, the parameter would be the same thing you passed to
is_post_type_archive
: tribe_eventsThere wouldn’t be any adjustment to the word (like events -> event), just because we’re using a different WordPress conditional function, just to clarify. The post type key would remain the same.
Here’s a reference on the requirements a post type key has: https://developer.www.ads-software.com/reference/functions/register_post_type/#parameters
Just mentioning to illustrate a WordPress post type key could be something like ‘abc123’ which wouldn’t have a clear way to make plural or singular.
To sum up, you could do something like:
if ( is_post_type_archive( 'tribe_events' ) || is_singular( 'tribe_events' ) ) : // Widget stuff here endif;
Note that the
||
is equivalent to an “or” operator, so the conditional would evaluate as true if you were on the events archive or a singular event.Can you let us know if that helps?
Best regards,
LelandForum: Plugins
In reply to: [The Events Calendar] White subscribe buttonGlad to hear. Thank you for the update.
Please feel free to open a new topic here if you have any other questions about the plugin.
Hi Owen,
It’s probably possible somehow. The template override system provides for substantial flexibility.
With that said, after looking at your site, I’m not quite sure what you mean.
When you say “the event page” do you mean a page like this? https://www.takingcareofelvis.co.uk/event/wyvern-theatre-swindon-2022/
I looked at the page and see a “BOOK TICKETS >>” link already stylized as a button (yellow-ish background).
I was wondering if you’ve already figured this one out? Or are you referring to something else?
If so, would you mind clarifying? Information like the link of an example page you are referring to, with an annotated screenshot indicating precisely which link you would like stylized as a button would be immensely helpful.
Best regards,
LelandForum: Plugins
In reply to: [The Events Calendar] Hiding the Date Picker BarGlad to hear. Thank you for the update.