Set Css based off URL in PHP Wordpress - php

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

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.

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!

Custom Permalink with Page Name Wordpress

I have looked all over the place and can't figure out how to get this to work.
I want my urls for blog posts to look like this: "www.website.com/my-page/category-name/blog-post-title"
The issue I am having is that I have a page called "my-page".
So I have a page "www.website.com/my-page/" which is just a standard wordpress page, but I want the url for the blog post to look like it is under that page.
Here is what I have for the permalink so far:
/my-page/%category%/%postname%/
But this doesn't work and gets a 404 error when opening a blog post.
At this point I don't believe it can be fixed through the wordpress gui, so if anyone has any recommendations, it would be appreciated.
Thanks!
Edit: I wanted to add that the permalink works fine if I remove "/my-page" or if I simply modify it so it does not match the page.
First of all you should not use the category in front of your permalinks as it leads to bad performance (and some posts may have multiple categories): http://ottopress.com/2010/category-in-permalinks-considered-harmful/
The second thing is - it should work. I tried with a fresh installation on WordPress and I get the correct results.
Did you flush rewrite rules / save the new permalink structure?
Did you publish a post?
Is your server correctly configured to use permalinks?
Third possibility - if your permalink structure does not work for some reason you can define a custom permalink structure:
https://codex.wordpress.org/Rewrite_API

Wordpress page dynamic content

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.

clean urls in wordpress

Im using page.php in wordpress for making a dynamic page.
Right now Im using photography/?cat=portraits
But I want photography/portraits
Im currently grabbing whatever is in my query string (cat=portraits) and only showing that content.
Where at in wordpress can I set up the routes or permalinks to be formated more simple?
Permalinks can be found under the setting tab from your WordPress admin interface
Follow this tutorial...
http://www.creativecitrus.com/wordpress-development/how-to-get-pretty-urls-in-wordpress
Or theres the Pretty URL plugin....but Ive never used that
http://wordpress.org/plugins/pretty-url/
Login wp-admin
Settings -> permalinks and choose custom structure place this sting and save it
/%category%/%postname%
If you have any problem in saving permalink please copy paste it in htaccess.
Or make it write permission for period.

Categories