WordPress wildcard subfolders - php

I need to make some subfolders aliases of main website. For example, I need that website.com/section1/ and website.com/section2/ act as website.com. I will use these folder as sections (regions) but the content will be the same for 80% of the site but will be sometime filtered by the section. I would prefer not to use multisite, I just want to categorize some data (pages, posts, custom posts) using these sections. If you visit website.com, you can choose which section you want and then navigate through website.com/section1/the-url-here.
Is it something possible?

Have you tried to use any of the Geo location Wordpress plugins like GeoPosty or SWG Location Aware it could be a solution that could save you loads of time

Related

How to block unused URLs in Wordpress Theme

I have made a very simple website (2 Pages) using Wordpress Waterlava theme. My website contains many URLs, for which I haven't created a page, but still they open up in the web browser.
e.g.
<my website URL>/author/user/
<my website URL>/category/uncategorized/
To block such URLs, I tried to comment template getter function names in array named $tag_templates defined inside template-loader.php. But this solution did not work. Any idea how I can solve this issue?
The uncategorized is a default category that could not be deleted. If you do not have any posts inside this category, the URL will not display anywhere in your website, because empty categories are hidden by default (99% in all themes settings). Now, if you want to stop these URLs from search engines, you may add them to robots.txt file via a reg exp Disallow. Last but not least, the author URLs
<my website URL>/author/user/
does appear, when you display the author's name inside your blog posts. You may see sometimes:
written by **author**
This author name is a link, that users of your website could click and see all the posts of the specific author.

Best way to share content between a Wordpress site and a Drupal site

I will try to be clear but if you need more information please do not hesitate.
A site approached me to make a partnership together. They want to create a new section on their site, say a "blog" section. The goal is to post my blog post on their site, in this new section, without having access to their admin.
So I need to set up something to be able to automatically share the content I post on my site with their site. My site is on Wordpress and their site is on Drupal.
For now I see 2 possibilities, but tell me what you think and if there is better to do.
First possibility: Create the page /blog and all the articles (ex: /blog/article-title) on my site, then set up a reverse proxy to redirect their request to my server. I have no experience with network setup so maybe I am completely wrong. But even if it works, I don't know how to fetch only post content (not header, footer) and change all urls.
Second possibility: Create a Drupal module, which they will have to install on their site, which creates the page /blog and the custom content type named "blog" when it is activated. And then use the feeds module to get the content from my wordpress feed and create a blog post for each post in the feed. With this solution, I won't have any header or footer problem, and the urls to the articles will be generated dynamically.
Every advice will be usefull. Thank you.
IMO, the easiest way to do that is to use the Wordpress REST API.
You could get all posts with this https://yoursite.com/wp-json/wp/v2/posts and get a specific post with https://yoursite.com/wp-json/wp/v2/posts/:id
full doc here : https://developer.wordpress.org/rest-api/reference/
I would advise you to use the second possibility, cause there are already several drupal moduls in the wild the read and import feeds from other sites.
Even more, WordPress will provide your posts also in oembed-format. With this you can use this Drupal Modul: https://www.drupal.org/project/soembed
You vcan adjust this modul to allow content from your website and display it on the Drupal installation.

Make special pages from WordPress theme?

I'm trying to figure out how a certain WordPress sets things up. I'd like to have a special page where I could make WP calls and interact with the theme, without affecting anything else.
I just making test.php and putting it into my theme's folder, but that doesn't work.
#Eliran provides one possible option, but you could also add a page in the back-end of WP, just make sure it has the slug 'test', and change your 'test.php' filename to 'page-test.php'. If you're worried about the public seeing this, set the page visibility in the admin to 'private'.
Edit:
to move your understanding along a little further also, you should review the way that WordPress determines what file to grab to render a particular URL. This can be pretty confusing to start with, so be patient if you're not familiar with it, but it's at the heart of designing WP themes. I'll link to the examples, and if you scroll down a little there's a diagram that, along with the text, will help you see how WP is 'thinking'.
http://codex.wordpress.org/Template_Hierarchy#Examples
You can see here: Page Templates
all you need to do is create a page named page-{custom-name}.php and add it to the theme folder.
and inside this php file add:
/*
Template Name: My Custom Page
*/
and than to use this page you need to go to the wp-admin, add/edit a page and chose it:
inside the php file everything you do is classic wordpress.
all this is giving you is a custom page tamplate.
Put it in your root folder. When you go to look at it, you'd look at www.mywebsite.com/test.php
It may be other ways to do this, but I rather use the rewrite API and custom query vars, to create custom routes.
A previous answer on the subject can be found here
The basic idea is to add a new url rule, catch the query var with the parse_request filter and maybe do a die or redirect to prevent the default wordpress template from loading.
I prefer this over theme templates, because with templates you need to create a page for each new url, and if that page gets acidentally deleted, that functionality would stop working.
What Pages are Not:
Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. WordPress Plugins are available to change the defaults if necessary.
Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories.
Pages are not files. They are stored in your database just like Posts are.
Although you can put Template Tags and PHP code into a Page Template file, you cannot put these into the Page or Post content without a WordPress Plugin like Exec-PHP which Read overwrites the code filtering process.
Pages are not included in your site's feed.
Pages and Posts may attract attention in different ways from humans or search engines.
Pages (or a specific post) can be set as a static front page if desired with a separate Page set for the latest blog posts, typically named "blog."
More About Pages.
In WordPress to add a new page you have to log in to the admin/backend and from the pages menu you can add a new page. In this case, you can select templaes for your page and also you can create a custom page template for that page.
You may read Createing a new page in WordPress. and custom Page template in WordPress.

Dynamic news required from different hosting server

I have a simple php website and I want to display my company news on homepage. I don't want to write html and upload on the server to display news. Is there any website that provides us basic CMS to create news and give us a short code that I can integrate on my website? And whenever I need to add news I will add on their website and it reflects on my website homepage.
The best route to go is to probably build either the entire site in Wordpress or build the news section within a subfolder like sitename.com/news. It's probably the most complete news/blogging engine out there, and it's easy to pick up.
If you host it in a subfolder, and still want to reference the articles outside of Wordpress, just be sure to include this in top of your home page:
<?php
// Include Wordpress
define('WP_USE_THEMES', false);
require('news/wp-blog-header.php');
query_posts('showposts=2');
?>
Just be sure to change the require() to point to your directory, and change the showposts count to the number of articles you want to show.
Wordpress has lots of other great resources on learning how to use it if you're not familiar.
http://codex.wordpress.org/

How to access files on Joomla?

I am in a critical condition. I was paying a developer in India who left the project but now I need to access the php pages.
I have explored the joomla site using the admin login but i can't find how he is displaying the html/php pages.
Please help!
I assume you're looking for the front-end template for the website.
Using FTP or whatever control panel go to the Joomla folder, look for a folder called templates - it should be one of the folders in there.
To check what the name of the current template is, go to the admin panel and look in the template menu.
If your developer has also made any custom components, the front-end part would be somewhere in the components folder, and the backend bit would be in administrator->components.
You need to read some Joomla tutorials. There are many places that can be used to "display the html/php".
First you have the template files that determine how the site looks and what module positions are available to be used. Generally there is one template in use but there can be multiples.
Next you will have components where the content is entered. At a minimum it is likely that you are using the com_content (articles/categories) and it is very likely there are others being used.
You will also have various modules that will display content in areas outside of the main content area. This will generally include menus, login forms, and other similar content.
Last, plugins can also have an effect on the content. In some cases plugins inject content and in others they replace placeholders with content.
There are a lot of pieces to the puzzle that all come together to display the resulting web page, it's not just a simple question of accessing some files.

Categories