Editing template content from the dashboard screen in Wordpress - php

I would like to set up a way to be able to edit content in my template form the wordpress dashboard or new admin page.
Something like creating input boxes on the dashboard, or on a new admin page, that would update specific content I have hard coded in my template.
I'm using a one page site (long scrolling), and would like to allow people to edit the separate content areas from an admin page.
(an existing plugin that does this would be fine too)
Thanks!

Related

Navigating links within custom WordPress plugin

I have created a custom WordPress plugin that will display a list of information and i will have the ability to add or edit this information. This seems easy but somehow i am not able to make it work how i would like it to. I have a list of companys and i am showing this list in a table. For each company, i can change its info.
I want to make it so when i click on settings or profile that the page will change and i will pass in the id of the company as a parameter.
I can add a new php page to the href but then that navigates to a new page and i am no longer in the admin dashboard. How can i navigate the url to another page with id without having to leave the dashboard?
When i created a plugin i created submenu pages and when i navigate to these pages... i am executing code all in the same file but different functions with different html which i feel is the way i want when navigating to Settings or Profile for a company.
You can do this by following the below steps:
If you admin/dashboard page URL is something like this: /wp-admin/admin.php?page=list then you need to add extra parameter for settings & profile page like this way: /wp-admin/admin.php?page=list&action=settings&id={id} or /wp-admin/admin.php?page=list&action=profile&id={id}
After that, you need to check if $_GET['action'] is profile or settings, then you need to render the profile page or settings page content respectively instead of list page content. Otherwise, if the action parameter is not set you can render the list page content.
Let me know if you need further assistance.

Front-end form (via page template) to control WordPress Customizer

I'm working on a project where I want to prevent user access to the WordPress dashboard. As a result, there are some items the user needs to have access to in order to populate and configure the site.
How do I create a front-end form (via WP page template) for editing theme Customizer settings like the header image and color settings?
I already developed front-end forms (via page templates) for creating, editing and deleting posts. What I don't have is a way for the user to edit a handful of options available on the Customizer screen.
UPDATE
I found update_option() to control site title/description, but still not sure about header image and color settings.

How to make WordPress pages where only certain (multiple) areas of content are editable

It has been a few years since I properly worked with WordPress. Now I have a proposal to build a WordPress site where every page has a custom design and only some areas of each page is editable.
The reason for this is to build a bespoke layout on each page which cannot be messed up by someone non-technical editing it in the CMS, except for small areas which they can customise.
e.g. A page contains one div which has some text in it, which can be edited in the WP admin backend, but the rest of the page cannot be edited.
Can this be done? How?
Edit: There needs to be multiple editable areas not just one. I know how to make custom pages/templates.
One method may be to create new page templates. Just create a new file in your main theme folder (or the templates folder if there is one). As long at the top of that file contains the line:
/*
Template Name: <your template name>
*/
You can design the page however you want. The data pulled from the admin section will go wherever you invoke
the_content();
The rest of the page can be hardcoded.
Then on the post edit page, on the right side (usually), you can choose the template with your template name for that page. It may be a good idea to copy the current post.php or single.php into your custom file and work from there.
For restricting access you can look at setting up user levels and keep your content contributors as "Authors" instead of "admins" so they can't change themes or edit settings.
(See https://codex.wordpress.org/User_Levels)
For creating specific unique pages with an area that gets changed you should look into custom Page Templates. You can create a page template by dropping a php file with the right naming structure into your theme hierarchy and it will get picked up by the back-end as template option when you create a page.
(See https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/)
I solved this problem using a plugin called Advanced Custom Fields which does exactly what I required.

Wordpress Plugin - Open Pages Inside Admin Panel

I am making a plugin. The plugin has pages that access a database, add, edit and delete records, call stored procedures etc. I have gotten as far as creating the plugin, and adding menus and submenus to the admin panel and having those menu links open in the admin panel. These are pages that handle the adding, deleting and editing of records in the database. Some of these pages have a link that would pass an id for example to another page in order to edit a record.
Those pages that are used in the admin panel of my plugin, that link to other admin pages for my plugin, do not open in the admin panel, they open outside of it. How can I create links in my plugin pages to stay inside of the admin panel of wordpress?
To clarify, I am able to add menu items that load pages in the admin panel. Maybe this screen shot will explain. So how can I open pages inside the admin panel?
In order to display your plugin's administrative UI within the framework of the WordPress dashboard you need to follow quite a few WordPress conventions.
The first is to write code for each administrative panel in a separate function. Each of these functions (one per admin panel in your plugin) must display the panel's HTML elements in a <div> object, allowing WordPress itself to wrap your divs in the dashboard display.
The next is to write a menu-building function for your plugin's dashboard menus, and then register that function with the admin_menu action hook. This menu-building function will contain references to your functions to display administrative panels.
Here is a writeup on the topic. http://codex.wordpress.org/Administration_Menus

Add custom html code snippet to my website

I'm a Wordpress newbie. I want to add a widget from another site onto my Wordpress website.
Here is the snippet:
<script type="text/javascript"
src="http://www.freshcontent.net/canada_news_feed.php"></script>
It will create something like a ticker on my site. I know how to add custom html to my posts. But, how do I make this show up on every page of my site? Are there tutorials for something similar to this?
Log into the dashboard, click on "Appearance" in the menu on the left, then choose "Widgets" and "Text". Choose the widget area you want it to appear in (these are theme-dependent, but can be customized any way you like), and then click "Add Widget".
Add a title, paste in your HTML, and click "Save". That's all there is to it.

Categories