Wordpress page dynamic content - php

i'm hoping someone can assist, with setting up a dynamic page in wordpress
We currently have thousands of images but i don't want these setup as posts, tho i still want them within the wordpress site, so I'm wondering is it possible to create a page domain.com/newpage and if accessed via domain.com/newpage?funny it would display the image funny.jpg from another directory on the server
Obviously id need to setup a custom page template which i can do but im struggling with the dynamic code bit
any help is appreciated

You can add images under Media in Admin. They would not be linked to a post but they can be used throughout the site.

Related

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.

Set Css based off URL in PHP Wordpress

I am using a website with a structure of www.example.com/blog
I have wordpress installed on the blog folder. I have a featured image that I want to have displayed on the www.example.com/blog but not on the actual blog post www.example.com/blog/post. They both use the same Css and I was wondering if I can do a conditional statement to set the display to none on the post page. I do not have access for the next 4 weeks to FTP in and change the actual code so I need a solution or advice.
I am not sure if I can use a variation of baseurl, as I am not sure how far it will back me out.
Google search didnt help me out too much

Adding AMP to wordpress posts with multiple page numbers

I am working on adding AMP to my wordpress single.php page. I have installed the plugin and am making the edits I need to have it looking correct. The issue I am having is many of my posts are multiple pages and I am trying to figure out how to get wordpress to render the other pages using AMP.
For example if i have a page with the url:
www.example.com/post-category/post-title/amp/
That would render perfectly using AMP BUT if I try to do:
www.example.com/post-category/post-title/2/amp/
That redirects to a different post instead of going to the second page of the intended post. If anyone has any idea of how to make this work as it should I would be very grateful. This is the last part I have to figure out to get my pages to work with AMP.
Thanks!

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/

Adding my own static webpage to a wordpress site

If my title wasn't clear, basically what I'm trying to do is to add my own HTML or PHP page to Wordpress, so i can play around with some web dev.
So essentially I just want a test page/pages added to my site. However since I have installed Wordpress on my website, I can't just add "index.html" to my root folder using my FTP client. I wonder if I can/can't do this and if so how to link to the pages I add using FTP.
Sorry if this doesn't make any sense. I just want to add some of the sites I've already made / ones I am creating to my site so I can easily show clients/employers what I can do, and I apologize again if I'm being an idiot.
Create a sub-directory in your root folder and then simply link to it:
www.domain.com/mysubdir/index.php
the other way to do this... create a page template in wordpress
create a php file named: template_mypage.php
You must put this php comment line at the top of your template file:
/* Template Name: My Page */
go to wordpress backend and create a new page
in the "Page Attributes", you can find a drop down list named "Template". In the list, you should be able to find "My Page"... select it and then save your page.
view it!
You can always create a subdomain or create a folder inside public_html/www/ and redirect it from any other domain or from any static link you have on wordpress
Why not use WordPress and put your portfolio together using Custom Post Types? I recently presented on this and there is a handy plugin for Custom Post Types UI that you can create a whole new section of your site and make templates for your portfolio.
Just a thought.
If you do a static page in WordPress, you can still template using the Page system as specified in another comment. Code your page, separate it into header, footer, content, etc files. You can load the file to your root, but not name it index. If you do a subfolder, you need to not have an existing page in WordPress.
HOWEVER, you can still do a "halfway" static page still using WordPress and do a header-staticpage.php, index-staticpage.php, and footer-staticpage.php and make sure to include the code for WordPress header and footer in the new header and footer so you can still reap the benefits of the default jquery that WordPress allows. Don't forget to name your template and when you create the page in WordPress, you can just leave the content area blank if you have hardcoded the page's content in.
I still recommend trying Custom Post Types. It is not hard and there are some great presentations in Slideshare that cover this aside from the plugin I mentioned earlier in this comment.

Categories