Wordpress: How to create frontend table using data from backend DB table - wordpress

I am relatively new to WP, and am trying to figure out if the following can be done, or if a plugin exists?
I am looking to save data (500K+ rows) into a SQL table (maybe a new table in WP database), and then render the results on a page (frontend) using some basic JS and CSS. Because of the size of data, I am not sure if I should use a plugin that imports from CSV/JSON and would it slow down the site.
Do I have to go all the way and create models and views and then render to an HTML, or is there an easy hack available?
As the last resort, I am also thinking of creating the table part using Flask and SQlite and use it as main domain, and WP blog as subdomain (don't know if it will impact SEO).
Request guidance from experts. TIA

There are plugins to handle table work. Use your favorite internet search engine to find them. You'll have to experiment with various plugins to get one that meets your needs if you go that route.
There two questions here.
One is how to render a table on the front end. If you do this yourself , your best bet is to create a plugin that defines a shortcode. When you write php code for that shortcode's handler, you will include code to read and render the table. You'll probably render it as an ordinary html <table>.
Then, you'll use WordPress's content editor to create a post, or a page, that contains your shortcode. When a visitor views the post or page, your shortcode handler runs and delivers the table you want.
The WordPress plugin API also gives you a way to enqueue css and Javascript to your pages. And, jquery is an inherent part of WordPress's page loads. WordPress also contains most of jqueryUI. That's handy, because there's a really nice jquery-based plugin called Datatables that will get your users some convenient features like pagination and sorting.
The second question is how to load that data into a table. The easy way would be to do it outside WordPress, with a SQL file or some other program to bulk-load it. But if you do it inside WordPress, you'll do it from an administrative page.
If you need to be able to add, update, or delete table entries from the front end, that's going to be some work.
Explaining all this in detail is far outside the scope of a Stack Overflow answer.

Related

Show plugin entries in frontend without using shortcodes

I just wrote a plugin that creates a database, populates and edits rows from the backend, now what I need to show a list view of those rows with teir respective link to a detail viewo of each one. The shortcode approach, I have already done it, but that does not get the purpose of my plugin, as I want it to be available in the Menus configuration, just like Woocommerce endpoints are. How can I do that? Has someone here done something alike?
Edit, I just realized that woocommerce just creates pages with the correspondent shortcode embedded in them. This just makes that more difficult.

wordpress: change the core table structure for ecommerce site

i have project that i need to integrate tables in different structure of wordpress. i am want to use woocommerce plugin and make it work with product table. i still want to preserve all woocommerce logic and features.
when thinking about that all i want to do is changing the way i want to get the data, i mean to the query. my question is, if there is a way to implement it with kind of service.
i thought about serviece with functionality:
1.disable the post meta request- i am still trying to figure out how to do it.
2.trigger hooks once before the request to DB trigger - this is where i will convert the query wordpress/woocommerce logic created to new structure that will fit my tables structure.
3.trigger hook once after i get response from request where i will convert it to structure worpdress/woocommerce need for using the original flow.
how much it will be complicated and which hooks or filters should i use.

Add dynamic content to a WordPress Page

I want to know the most elegant/best practice way to do the following:
Let's say I have some PHP that returns a string (today's weather, for example). I want to be able to include the string within a WordPress Page, but not by using a plug-in to allow PHP within a Page.
So for example:
This is content of the page that is editable via WordPress pages.
Today's weather is THE_WEATHER. This bit is also editable, but as
an editor I can't edit the PHP that just told us what the weather
is, the developer does that.
What is the best practice way to do this (preferably without using plug-ins)?
Offhand, it sounds like you want to define a shortcode that lets you invoke the PHP function you're talking about and insert its result into a page/post. This pretty much means that you're writing either a (very simple) plugin or you're incorporating the shortcode definition into the functions.php file associated with a theme (which can be a simple child theme of the one you're using).
Which to do probably depends on whether or not you're likely to change themes (if it's just one site) or whether or not you need to do the same thing on different sites that can have different themes. If either is the case, then you should write it as a plugin; otherwise you can just make it part of your theme.
Consult the Codex to learn how to define shortcodes.

Set the permalink to any domain in Wordpress

Is this possible to achieve without too much effort or a plugin? It's simply to instantly redirect to a site I've made in my portfolio if the post doesn't have any content.
Note that I don't want a script in the actual post to redirect since I only use Wordpress as the backend and fetch all the data to be used by a JavaScript backbone app.
EDIT : Added some extra info in a comment
Short Answer: No. You cannot set your Post Permalink to an external asset without directly editing the database.
Long Answer: First off, you need to understand the purpose of the Permalink. It isn't just an arbitrary link to somewhere. It's reserved specifically for storing where that specific post lives within the context of your Wordpress installation.
Your post doesn't live on example.com. It has its own ID, and Wordpress has a specific spot set aside for it where it can be seen on YOUR domain. Leave it as such.
Instead, what you should be doing is employing the tools Wordpress gives you to achieve what you want. A Plugin doesn't exist for what you want because - quite frankly - it's a fairly trivial task when approached CORRECTLY and doesn't warrant the use of an external resource.
So what's the correct way?
Use a Custom Field. Name your Custom Field something like 'externalHref' and fill that in with your link to the website you want to point to in case there's no post content.
Then in whatever templates you're using to generate your posts, just check either for the existence of your Custom Field called 'externalHref' or check for the non-existence of Post Content. In either case, instead of generating a link using The Permalink you can simply build a link that points to wherever you need.

WordPress Plugin Development Idea? Is this possible? Am I on the right track?

I'm very new to WP development. I host a website which needs a list of trails (hiking, biking, etc) and I'd like to write a WordPress plugin to do it.
Can someone please tell me if I'm taking the right approach, and if what I'm proposing is possible.
I'd like the site to end up with an auto-generated and filtered index at http://example.com/trail-guide, and the discrete trail info pages at http://example.com/trail-guide/trailname. This data would all be stored in a single database table holding info for each trail, with an admin page for adding, editing, and deleting entries from here.
Is a WP plugin the best way to go about doing this, or should I be looking at something else?
From the way you're describing, your best bet would be to Register A Custom Post Type. This can be done by adding to your existing theme's Functions.php file, or by creating a plugin.
If you don't plan on changing themes, my advice would be to just hardcode everything into your functions.php file. Otherwise, creating a plugin for this particular job would be the safest alternative.
Using this functionality in tandem with Custom Meta Boxes and Custom Taxonomies will allow you to keep everything organized within the Wordpress Framework with your own special data.
This means that these new posts can also be queried at any time through the standard Wordpress Loop or search box.
If you are uncomfortable with writing your own functions to extend your existing framework, you might want to look into some plugins like GD Custom Posts And Taxonomies Tools to manage your own.
Hope this helps.

Resources