Wordpress Implementing Onepage - php

The situation is, I'm currently creating a website from scratch for a client, one requirement is Wordpress, and the layout is a "One Page Layout". Since it's my first project developing a scratch theme for wordpress, I have question concerning the method used by experienced users here to achieve the One Page functionality.
So, I achieved this functionality by:
1 - Creating Child pages of Home, and assigning a page template that matches a section (team, hero, about, contact ...). The cons in my opinion is the custom labels for each diff section, hard for client to manage, the wordpress "page editor" lacks functionality.
2 - (method used) created a "one page template", and implemented a widget area (sidebar) for the sections, and created a custom plugin for the team that adds widgets to the wordpress dashboard, then the user can add them in "Widgets > One Page Area", and edit the contents of each sections. Pros, it's easier for the client to manage the widgets and order the sections in homepage. Cons, I think that it's not a "good" way of achieving one page functionality with widgets.
So, I would like to know in what kind of way you implement a onepage functionality in wordpress theme developing.
PS: I don't want to use a plugin already created since it's also for University and they don't want me to use other developers plugins.

Related

Wordpress Dev: Understanding Scope of plugins or general WP Architecture

I am trying to understand a bit about how WordPress works in development..
I already created some shortcodes that I can just edit in on my page and some WIdgets that seem to display on every site or blog post that I created...
My question is: What is the general scope of the widgets or plugins in WordPress that I create? I know there are hooks and WordPress API functions to only show them on specific parts of WordPress, e.g on the admin-panel, or just in the widget sidebar of a page...
But are there some good sources about the architecture and scopes of how and where to use your plugins? Are they kind of injected into every page I create on my WP pages? (e.g with enqueue_scripts or so?). It's just a bit too overwhelming for me as a beginner to get a good overview...
And how are those functions from WP API made accessible in my plugin files/folders when I never imported them? I guess it's based on some module technique but no idea how..
It's good to delve your feet into the WordPress (WP) new concept called blocks you can find all the details here: Block Documentation
Creating widgets and shortcodes is a way older process nowadays most people keep their eyes on WordPress Blocks and especially FSE (Full Site Editor) therefore I would suggest you start learning that thing ASAP.
Let's come to your queries:
How WordPress works technically
Go to your WordPress directory you will find the file called index.php which is responsible for bootstrapping your application
Along with the index.php you will find a few directories called
wp-admin
wp-includes
wp-content
wp-admin
Where WP have all functionalities happening in the admin part are executed by accessing classes and functions present inside of this directory
wp-includes
This directory has all the utility and helper classes and functions
wp-content
This is the only directory developer can add/edit the files which store all of your plugins, themes, uploads, and other custom directories if your
code or any other plugin code created
For more details on how WP works
It's quite a challenge to explain all the ins and outs WP in a single post but you can find the detailed explanation in the official documentation
WordPress mainly depends on hooks and hooks are come under any of these two categories:
action hook
filter hook
For more details on WP hooks
How do plugins or themes work?
Both plugins and themes have a terminology called headers using that header metadata WP fills all the details in the plugins listing admin page and in themes listing page
For more details on header
Themes mainly depend on the concept called loops which responsible for fetching the posts data and build the necessary details using template tags and iterate them using the loop. Based on the type of page the user visited WP uses the template hierarchy to render the page as per the request that happened on the client end.
For more details on how WP loops works
For more details on how template hierarchy works
Headless CMS
Yes, you can make your complete WP into a headless CMS with the help of WP REST API. The REST API is used to access WordPress outside of the WP for e.g. if your android app need to fetch any posts or categories or user from WP using this REST API it can do that. Also you can create your custom endpoints too
Additionally, try to explore WP CLI
I believe that I covered most of the things required to understand how WP works, to be clear this post abstracted many of the things to make it as compact as possible for anyone who started entering into the WP development.
If you like to know more of these abstract explanation in a detailed way then always visit the official documentation
If your ide have an auto-complete feature please try to explore all of these functions (wildcard list) which contains most of the security functions provided by WP
is_*
exists_*
validate_*
sanitize_*
esc_*
*kses*
*nonce*

Custom wordpress portfolio

I'm making a portfolio page for a photographer. The photographer should be able to add new projects via wordpress. I am not really familiar with how wordpress uses the inputs for an "post" or "project" to create a new portfolio project.
Currently I have an intermediate knowledge of HTML and CSS. How would I be able to assign my own styles to content that is yet to be created? I figure this requires knowledge of PHP?
I understand this is a pretty general question and I apologise for my question is too vague. Searching for solutions has yet only given me plugin solutions.
In order to create a custom WordPress template not only requires some basic PHP knowledge, but also WordPress template knowledge. You can read all about them here.
I would suggest to use a theme instead. There are countless (the link is just an example) amazing portfolio themes, lots of them free and all of them responsive. If you want to go along with your current theme and use just a plugin to create those portfolio items, I suggest a plugin like Advanced Custom Fields.

Widget or Plug-in? Building a theme and unsure how to approach optional content

I have a question regarding how best to build a widget/plug-in for WordPress.
I have tried to code this thing out but unfortunately to no avail but that's because I'm increasingly thinking I'm going about it the entirely wrong way.
This is what I'm trying to achieve:
I have built a theme from scratch. In this theme I have two content areas. The larger of the two contains the main content and the smaller of the two (proposed widget/plug-in) contains supplementary information (opening times, Facebook feed). I don't want this widget/plug-in to appear on every page and would like the ability to turn it on or off within the usual WordPress admin area.
The impression I am getting is that I can build the widget that contains the content I want (with necessary forms to change said content) but it is either on for ALL pages or off for ALL pages, no sort-of page specific functionality. That's where I'm thinking a plug-in would extend the functionality and allow me to be more page specific with it. That is my current set-up with a theme I'm running and plug-in I added (neither of which were coded by me) but I would like to repeat it as best as possible.
Would it be right to assume that widgets are not really designed to have page specific functionality and that function should be left down to a plug-in?
I appreciate this question asks nothing really in the way specific advice but I would just like an opinion or two on the best approach before I go away and create it - this is my main struggle at the moment.
Thanks for looking.
This can be done with the Jetpack plugin. Once activated you can choose what widgets display on what pages:
The Widget Visibility module enables you to configure widgets to appear only on certain pages (or be hidden on certain pages) by using the Visibility panel.
Visibility is controlled by five aspects: page type, category, tag, date, and author. For example, if you wanted the Archives widget to only appear on category archives and error pages, choose “Show” from the first dropdown and then add two rules: “Page is 404 Error Page” and “Category is All Category Pages.”
Originally posted here
It is also possible with the Display Widgets plugin.
This is a common problem. The usual remedy is to use an existing plugin that allows widgets to be tied to pages.
The 3 most popular plugins for this are:
JetPack
Per Page Widgets
Widget Logic

How to add a widget by its shortcode on Wordpress posts / pages?

Is there any way we can assign a shortcode to already created widget and later use that
shortcode in our specific posts and pages to show that widget instead of trivial method of
showing widgets in sidebar ? I googled about this stuff didn't find anything relative.
Any suggestion would be welcome!
Yes, You can call widget in Post/Page using shortcode. Follow this link to establish a system like that.
http://digwp.com/2010/04/call-widget-with-shortcode/
This might be relevant.
Widgets on Pages
https://wordpress.org/plugins/widgets-on-pages/
Observations and two questions:
This plugin allows insertion of 1 or "sets" of widgets via shortcode into pages, posts, (and Custom post types?) and it will also save a list of configured shortcodes~sets. VERY handy!
When comparing its features to the plugin Widgets Shortcode, that plugin does not provide a means to save "sets" of plugins, rather it seems to focus on inserting widgets individually. In fact, it inserts the shortcode for each widget in the bottom edge of each widget and it assigns different shortcodes to each instance of a widget. Also nice.
https://wordpress.org/plugins/widget-shortcode/
I like the granularity Widgets Shortcode provides with an individual shortcode for every instance of every widget. When running it and your plugin simultaneously even widgets saved in your plugin's "sets" are still assigned individual shortcodes. Those individual shortcodes allow using a specific widget out of a "set" in a different location without needing to create an additional instance of the widget as it appears would be required with your plugin.
Incidently, for anyone who wants both of these features, these two plugins play very nicely together on one of our WP 4.0 Multisite installations with 50+ sites and even on a site using the theme Make.
FYI: We also tested amr shortcode any widget, but had some issues with it and rather than troubleshoot it we moved on. To be fair, we were testing quickly on a site with over 160 plugins active. Yes, 160 plugins. I know, I know, but think about it for a minute. Any plugin that you can activate into that mix of 160 plugins and it does not break things or introduce issues, then it suggests a good probability of it being troublefree to use.... well at least until the next round of WP updates. :)
We also tested Widgetize Pages Light and its pro version Sidebar & Widget Manager and had no issues with either. However, if only seeking to insert widgets into pages and posts these plugins seem like overkill as they provide additional page layout functions that may duplicate theme functions and/or other plugin functions.
I was looking for a "widgets in pages" plugin that provides a TinyMCE button to insert the widget shortcodes.
Can anyone recommend one that has a TinyMCE button to insert the widget shortcodes in pages, posts and CPTs?
Ultimately I selected Widgets On Pages as having the best combination of features for this application. Its simple to understand, easy to use, versatile and has worked flawlessly for us, even along side Widgets Shortcode.
You can do it by wordpress WordPress Widgets Shortcode plugin, you can Embed any widget area/dynamic sidebar to your pages/posts using this plugin as a shortcode
edit widgets in wp :
file in # wp-includes/widgets.php: register_widget()
in source view sample :
public function register( $widget_class ) {
$this->widgets[$widget_class] = new $widget_class();
}

How to make Wordpress plugin pages look like the standard admin pages

I'm new to writing WP plugins. My plugin code is ready so I'm working on the admin pages.
Is there an easy way to create similar tables and forms as the rest of WP admin pages or one is left to reverse engineer those interfaces or make his own?
There's an entire documentation section about it. Also, there's a plugin to help you style your plugin, that shows all the styling used by the admin interface.

Categories