Questions regarding wordpress - php

I am a developer who has never used wordPress before and just had a couple of questions about creating a custom theme
To create a specific look to a website do I create a static design then inter grate it with wordpress and add the dynamic content where it needs to be added?
If you create a custom theme how do you make it dynamic rather then being static? When I switch themes I loose the all the appearance menu options such as (menu, widget, header and background) How do i create them?
For stuff like image carousels if I want the images to be dynamic do I create a widget for it in the functions.php file?
For all the text on the page do I just spit that out thru the visual editor? seems to break links when editing
What are starter themes?
Sorry I am quite new to Wordpress but have knowledge in html, css, js and php but I just struggle to understand how to integrate a custom design and make it all dynamic

As a first step to create a basic new template I would recommend you starting with one of the default WP themes (e.g. Twenty Fifteen), leave all the core files (they contain dynamic parts e.g. functions loading header/footer/content) and just customize the css files and images. Further customization would require changing code in php files (e.g. header.php for the header, index.php for the homepage, single.php for the article page, etc.)
It is true that some options related to header, background, etc. can be theme dependant, so when you change it the configuration gets lost, but the others like menus and widgets remain like they are when switching themes.
Yes, for stuff like carousels you usually have to use custom widgets and plugins, you can find some really good ones on the web (e.g. this one), so you just upload the images and apply configuration in the backend.
Yes you use the WordPress editor (as you see it has Visual and HTML view) for all the user content within the pages and posts. Broken links might be cause of using relative paths, just make sure they are complete.
As mentioned in the first point you can always start with the default WordPress themes like Twenty Thirteen, Twenty Fourteeen, Twenty Fifteen etc.

Related

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.

How do I customize content in the WP starter theme Roots?

I am fairly new to WP and very new to Roots (http://roots.io/) and I am having trouble creating a custom home page. Here's how far (I think) I understand it:
To create a custom home page I put a file named "front-page.php" in the WP root directory. This file is based off of "page.php".
"front-page.php" loads "content-page.php" from the templates directory.
And that's where it gets a bit fuzzy to me. The function "the_content()" lives in "content-page.php" and I'm assuming it loads the content of the page but it's loading some default stuff (I think it's added by the Roots theme) that I don't want there. I don't think the proper way to customize the home page content is to modify "content-page.php" and remove or change the function "the_content()". I'm assuming there is a better, modular way to do this, possibly creating a custom class that will be loaded when "the_content()" is called but I don't know where and how to do that.
As you're a bit vague with the details I'm going to have to read between the lines a bit. If you need further clarification just ask:
the_content() just outputs the content stored for a particular post, which you would edit in the WP admin. In terms of editing the markup that surrounds the content you have a couple of options. You could edit content-page.php as you require, or create a new partial (such as content-home.php and load that instead.
You can also use filters for modifying content; these are often used to change content that appears in multiple places such as 'read more' links. Check out this introduction to filters for more info.
In closing, you don't want/need to edit the_content()

How to handle user customizable website themes?

We are developing a CMS and would like advice on the best way to handle user customizable themes. We have a couple ideas but are not really sure what the best approach is. The CMS will allow the user to customize every part of the site including colors, fonts, layout, etc, through a theme editor UI built into the CMS.
We were thinking writing a custom CSS parser that writes changes out to a CSS file for that theme. This approach seems like it may have a lot of point of failure and a lot of overheard.
The other way was to store all the CSS in a database and then just use inline CSS.
The CMS has been built using JQuery and PHP with MySQL database for user information and content, but not CSS.
Is there a more efficient way to parse/control/edit CSS properties of the theme?
Thanks
My suggestion is to take a look at the way WordPress or any other pre-built platform (Drupal, Joomla, etc.) approaches this. WordPress themes consist of template files stored on the file system that allow users to have complete control over the look and feel of their Web site. The CSS for each theme is stored in a file called style.css. WP itself does not enforce a frontend layout but instead leaves that in the hands of the site administrator/developer.
I would treat your CSS files as if they were code classes. For instance, have a CSS file for your customizable font themes, one for page themes etc.
With that in mind, on page load you can easily build a dynamic CSS file based on user selections.
AKA
font1.css
font2.css
font3.css
page1.css
page2.css
page3.css
On Page load you identify that user preferences are font 1 and page 2, pull in both css files and walla you're good to go!
I am currently looking to do the same thing. Some of the solutions I've come across seem to use an xml file for the layout and then (probably) parse out a custom css file. This way, the layout determines the "stacking order" of page content modules and the other customizable features (which are usually limited) such as fonts, colors & background image are handled by an additional custom (user)css file.
I'll be following this one and will also be interested in finding actual code solutions to making it happen. For instance how to use jquery to build a draggable content module interface for the user backend.

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

Using WordPress as a CMS

I am currently teaching myself WordPress and working on my own CMS site.
My site will consist of approximately five pages where the header/sidebar menu/footer will be seen on all these five pages.
Beginner here and questions are as follows:
All these five pages will consist of different content, for example, every page will have a image banner representing the menu option just clicked, for example, "About Us" on page 5, "Promotions" on page 4 etc and then some text beneath that and then possibly some images inside a carousel set up.
Within WordPress, how would I tackle this, i.e. do I just create a page in WordPress, position the banner image at the top of the page, then have a few breaks and then insert the carousel of images - is this correct?
If not, do I need to create a separate php file called aboutUs.php that has this markup and then somehow link it to a WordPress page?
On my landing page of my site ONLY (page 1), just above the footer, I want to display a div section that displays all the sponsors of the website along with a URL to click to their websites - how would I go about doing this in WordPress?
Furthermore, with my menu, how do I link my menus to point to the WordPress pages relating to that menu option?
If you use the 'default' template that comes with WordPress you could do something like this to generate different content on different pages without creating separate php files (this would go in page.php):
<?php if(is_page('About Us')) { ?>
<?php $about_query = new WP_Query('category_name=aboutus-&showposts=1');
while ($about_query->have_posts()) : $about_query->the_post(); ?>
<?php the_content();?>
<?php endwhile;?>
Essentially, in this you could just create a post and an 'aboutus' category to reference it. The page of 'About Us' (referenced through is_page()) would contain the content you wanted to display.
First, some background. Wordpress has a number of ways to display stuff, such as images, text, and query results; here's a list:
THEMES
You can modify your theme files directly to do whatever you like. This will probably involve learning a lot about PHP and the Wordpress internals, but there are plenty of books, and the Wordpress Codex to help you. You can get themes from the Wordpress theme directory.
PLUGINS
There are huge numbers of Wordpress plugins, any one of which might fit your need. Plugins will require configuration, but generally won't involve learning PHP -- just how to install and configure them. Most of the SEO (Search Engine Optimization) plugins will allow you to place custom HTML in the templates (nominally for ad placement, but you can do anything you want with it). You can get plugins from the Wordpress plugin directory.
WIDGETS
The base Wordpress software and many plugins provide Widgets. A widget is a display element that can be docked in one or more widget areas. Typically a widget will be a chunk of HTML (often an unordered list) that has the theme's style sheet applied. Widgets are often used for ad placement, navigation elements (menus, dropdowns, breadcrumbs) or to provide tag clouds, category lists, calendars, etc.
SHORTCODE
A shortcode is a macro that can be placed in a page or post, that will return a chunk of HTML. Shortcodes can take parameters that will affect what the shortcode returns. The base Wordpress software provides some shortcodes, but many plugins will provide shortcodes as a way to get more functionality without the need for widgets or theme modifications.
With all of that in mind, here's my answer(s) to your question(s):
Modify your theme to include a page template, and add your image selection code to the template. Then create your individual pages, and then select your template while editing the page.
The 'landing page' can be any page (instead of the default blog index page); create a 'home' page and a 'home' page template that includes your advertisements. Alternately, use a SEO plugin to add the ads above the footer.
I don't know what theme or plugins you use, but generally you can configure a navigation menu to work from a list of pages, specifying either which pages to include or which pages to exclude. If your theme doesn't include this functionality, I'd recommend choosing a different theme.
Look into Wordpress "page templates". The Wordpress codex can help you understand this.
If you edit a post in WP you will notice the option to use a template. That is your goal. Learn how to work with them.
Wordpress themes are composed of multiple files. One of them is the header.php file which contains the header content. The footer.php file contains the footer and the sidebar.php contains the sidebar. These are the usual conventions. They're not strict. There will be a couple of main files which include these (e.g., index.php - Used for articles, page.php - Used to display pages etc.)
If I were making a setup like yours, I'd make five "pages" (using the backend) and then customise my page.php file to present it properly. I'd still keep the header, footer and sidebar separate from the page.php file since they'd be there for pages like 404s etc. as well.
Just put something in the content of the landing page to display this.
IF you're doing theme development, the right place to look at is http://codex.wordpress.org/Theme_Development

Categories