Get Wordpress sidebar from another Wordpress blog? - php

I want to write a plugin that will pull a sidebar from one Wordpress blog and place it in the sidebar of another blog. I know to write a plugin, but actually don't know where to start with this idea.

I believe he's saying that he wants to write a plugin to be able to retrieve a sidebar from another website and display it (possibly as a widget?). If that is not the question then I apologize; otherwise, I'll take a shot at answering.
The first thing I would recommend would be to view the code of just about any other widget plugin to make sure that a plugin (and not just some JavaScript) is really what you want.
Assuming you want the plugin, check out this resource for some basics. Also, you'll need the retrieval code which will either be "screen-scraping" in PHP or AJAX partial page loading with JavaScript.
I hope any or all of this helps you get where you're going.

Related

What is the best way to bypass Wordpress's HTML sanitization so I can use bootstrap html in Wordpress?

I'm trying to get on developing websites on Wordpress for easier management for the future admins.
I have created a bootstrap theme on my own. I got all the pages smoothly into Wordpress and are now easy to edit. However I have this one page which has tables, buttons, glyphicons and once I click the "graphic" view while editing the page it breaks it.
So I was thinking that that won't do and I decided to create a new plugin to fix this problem. A simple plugin which has few textboxes on the admin settings page and then just prints the texts on the page where I want them to go.
However I tried to look for tutorials and I'm just overwhelmed. I have gotten my plugin to work somewhat. It has a admin setup page and it can print customized text to a page where my shortcode is. Thanks to this post!
However, I still don't know what to do from this point on.
My question is: Could you help me by giving me an example code to get the same kind of textbox to my plugin's admin page as I have while editing/adding new pages (with graphic view) which saves the text and displays it on a page.
I have no idea if this is the way to go but I can't think of anything else right now. I was thinking that the settings page has a couple of textboxes and the text in them goes where I want it to go on a page. So the future admin won't see the unnecessary html code and therefore can't break it.
I would abandon the "plugin" idea. There are several more elegant ways to do this besides writing a plugin.
By far the easiest to implement is this:
1. Store the html in a "Custom Field" https://codex.wordpress.org/Custom_Fields
2. Display the contents in your page (or post) template https://codex.wordpress.org/Custom_Fields#Displaying_Custom_Fields

Wordpress Styling

I am new to using Wordpress as a developer as opposed to just using the dashbord but am struggling to understand a few things and would really appreciate some help.
For a site that does not require a blog - do you just create custom/specific page templates for each page that your site requires?
If so - presumably you code the content directly. But then how does the client edit their website's about page or any other page for example - because doing it through the dashboard isn't going to use the necessary CSS hooks without using classes, id's and HTML?
As a beginner to Wordpress - I can't see that posts are used on sites that don't have a blog, but am I correct or is using posts the way a client can edit content on their site, but just have posts styled to look like normal content?
Or am I wrong in thinking a company (I am starting as an intern at a web dev company that use WordPress) provides the tools or at least configures WordPress to enable the client to change content?
Any help getting me to understand the basic concept and way a developer would create a custom WordPress site would be much appreciated. Thanks in advance.
You can use page.php. In WordPress everyone create at least one custom template type to get wider design for custom pages.
You can refer here for more info.
Use Advanced Custom Fields with page templates. Say you are making an About page, call that template about and select that template in the backend editor. Once you save the page, the acf fields will show up and you can populate the content.
ACF: https://www.advancedcustomfields.com/
Page Templates: https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

Wordpress plugin using existing theme

I am building a plugin for the first time and I have setup my rewrite rules to call a PHP file I have located in my plugin folder and this is working but all I have it output just now is "test"
I wanted to ask, is there is a way of pulling in the existing theme and using this as the basis for the page, then I can have my plugin just output the page content area so to speak.
My plugin is quite big in terms of the amount of data it handles so I would like to be able to use a menu link to the aforementioned file and this file can then output all the sub pages of content but still using the default theme (theme I have made) and fill the content area only is this possible and if so is there anything to explain this already available because I couldn't see it.
Any help with this would be much appreciated.
Edit: I have tried including a file from my current theme but this will give me a 500 error so I assume its not as simple as this.
Have you thought about using custom post types for your plugin content rather than relying on custom tables and separate code?
Other than that, you could use a shortcode (just one) and have users insert that into a regular WP page, the shortcode then displays all of your various plugin stuff.
It's hard to be more specific without understanding why you've done it this way.

Modifying wordpress to create a customized CMS

I am working on moving a normal HTML website to Wordpress for a client. It's a simple website with a lots of images and HTML text. The idea is that client should be able to modify contents of website through the simple CMS without actually looking into code.
While doing analysis I came across some roadblocks like
Problem: If I want to modify text/ image for Header or footer in wordpress, I will need to do it in PHP code.
Solution: Create a customized header/ footer update tab. Modify database to store these contents and modify PHP code to directly read the data from database.
Problem: Wordpress provides a set of widgets (blogrolls catergories etc.), I need more like Latest News.
Solution: Modify PHP code and datbase, basically create your own widget.
Problem: There are a lot of static HTML pages which are linked from one page to another.
Solution: I don't see any way in wordpress to create static HTML pages which among which we can create links from one to another.
Solution: Create a new interface where user can create HTML pages/ plain text content. This will return a link which can be used to provide hyperlinks in another page.
My query is: Are the solutions mentioned above correct? The problems mentioned look very common, so is there a tried and tested way to solve?
Edit: User (Client) want to use wordpress. Just wanted to make sure here that Solutions I am thinking about are correct. So would like to have suggestion from someone who has already worked on Wordpress and solved the problems like I have mentioned. Do not want to reinvent the wheel.
I've worked a lot on a Wordpress-base white-label CMS, so I think I can help you in some ways.
First of all : always remember the real power of Wordpress is its community and its plugins base (that you can access directly from wordpress admin)
Problem: If I want to modify text/ image for Header or footer in
wordpress, I will need to do it in PHP code. Solution: Create a
customized header/ footer update tab. Modify database to store these
contents and modify PHP code to directly read the data from database.
If you want to have a fully customisable appearance, I suggest you to start from a theme like Consctructor. This is a theme with a whole admin panel for simple appearance editing. The code is far from perfect but this is a good start.
If you just want to manage the content of header / footer, you can do it via Menus / Widgets / Links, but only if your theme is designed for that. For example, a lot of good theme allow you to add widgets in footer, then you can construct your footer with only a few drag-n-drop in the Appearance/Widget menu. For header image, the default theme (Twenty-Twelve) provide an header panel where you can upload a new image.
Problem: Wordpress provides a set of widgets (blogrolls catergories
etc.), I need more like Latest News. Solution: Modify PHP code and
datbase, basically create your own widget.
Yes you can create your own widgets for specific needs, but I suggest you always start from an existing one. There is a lot of plugins providing you dozens of widgets. Explore that before reinventing the wheel.
For your specific case, a 1s google-search returns me this plugin.
Problem: There are a lot of static HTML pages which are linked from
one page to another. Solution: I don't see any way in wordpress to
create static HTML pages which among which we can create links from
one to another. Solution: Create a new interface where user can create
HTML pages/ plain text content. This will return a link which can be
used to provide hyperlinks in another page.
No, use the pages. Wordpress Pages are static content and this is editable, and for each page ou have a permalink. If Pages aren't good for your job, you can consider creating a custom type (or install a plugin that create a custom type).
Wordpress themes can be made to accept images and stuff like that.
The are ample wordpress widgets to do just that. Just be sure to find the right one.
I don't understand this one. You can create any amount of wordpress pages, and to link between them is easy. If you want your files to end in .html, simply enable permalinks and specify that option. It's very easy.
Reinventing the wheel sometimes is good, possibly even good for you (Given patience and time). Nothing is prepackaged to do everything for you, hence these are times when you need a custom build.
Anyways, CMSes don't come as a multipurpose, all-in-one package that solves your programming woes and turns everything into a point-and-click solution. Every CMS is unique, designed to serve a specific purpose. Others general purpose, others for blogs, others for very simple sites.
If you don't find anything native that fits your needs, find the right plugin for the job. If you cannot find anything at all, then might as well build a custom solution, or build on top of an existing resource. Innovate

Wordpress pull Blog Post

I'm designing a theme for wordpress. I need advice on how I would construct it.
At the bottom of my Frontpage/Home I will put a snippets (a title and a short description of blog post) of what is new in my Blog .
Preview:
Question:
What approach should I use? I can make the bottom page widget ready and will just use widget or will use PHP to pull details in my 'blog' page (I dunno how to do it php, a link would be useful)
what is the proper approach? I'm designing it for a client. My concern is If I would make it widget ready, client would have to install the widget. If I would do it on PHP, (I have no resource and idea in doing that )
Thanks!
You'll need to know some PHP and JavaScript if you want to make a WP theme from scratch. Otherwise I would suggest to modify an existing one.
Here is the theme development help from WP.
You'll have to run a loop, in which you'll retrieve the posts from the database (Wordpress handles that) and show them as needed.
The Loop In Action and
Building Custom Wordpress Themes
Hope that helps

Categories