Update permalinks wordpress via PHP - php

Ive just created a new custom post type on the wordpress website of a client. However the original author of the template disabled the 'settings' menu in the Wordpress Dashboard, so I cant update the permalinks through the dashboard. I can't seem to find the location where he could've disabled it, so im now looking for alternatives.
1) I downloaded a lot of the server to find the "remove_menu_page( 'options-general.php' );" line of code, but as said i cant find it.
2) I've heard of the flush_rewrite_rules(); functions but im a bit sceptical to use it as I'm not 100% sure what it does and dont want to screw up existing pages on their website.
Any insight or advice on any of the two topics?

Use it like this in you functions.php and run the website once, then you're free to remove it.
function custom_rewrite_rules(){
flush_rewrite_rules();
}
add_action('init', 'custom_rewrite_rules' );

Related

How to remove admin submenu item of WordPress Plugin?

I installed the following plug-in to provide testimonials for my WordPress site.
https://codecanyon.net/item/testimonials-showcase-wordpress-plugin/6588139
The plug-in somehow creates a submenu „Group“ with link „edit-tags.php&taxonomy=ttshowcase_groups&post_type=ttshowcase“ which I would like to get removed as there is no need for my case to have such groups.
So I reviewed the files on the plug-in’s directory but can’t find where the menu is created. It somehow looks to me it’s there by default or similar.
So I tried adding a function to the plugins main php file using „remove_submenu_page“, but that’s just crashing the whole site.
I would appreciate some help. Thanks.
add to your functions.php
remove_menu_page( 'edit-tags.php&taxonomy=ttshowcase_groups&post_type=ttshowcase' );

Wordpress customizer.php has no style when trying to edit

I recently uploaded my website online and following that, I want to edit a few new things but as shown in the image above, the page has no style. The wordpress theme I bought is heavily relying on templates and the only way to edit them is through the customizer but I am trying to look for a solution and seem to find none, is there anything that can be causing this? I deleted all plugins that are not needed incase it was some plugin breaking it but that does not seem like the case.. any help?
sidenote: in the localhost the customizer works fine, its just that when I published it online when this issue has occured.

Wordpress plugins not working with custom theme

I'm new to WordPress and actually repairing a page as a favour. The page was originally created by an inexperienced developer which is why it has its faults.
My main concern is that I don't seem to get any of the plugins to work. The page has a custom theme. I tried switching to a previously uploaded theme and all the plugins worked like a charm on that.
The client seems reluctant to abandon the custom theme and short of having to take it apart piece by piece I'm trying my luck here.
Both wp_head() and wp_footer() are called and seem to be in the right places, wp_head() right before the </head> tag and wp_footer() right before the </body> tag.
What am I missing?
This is a very general question, but here are some starting steps to try and see how you get on...
In wp-config.php add or alter the following: define('WP_DEBUG', true);
This enables debuging to screen and will throw up any errors.
I would still advise you then try the plugins one by one - in theory once you get one working then the others should be ok. There is more to a theme than just having wp_head() etc... make sure the loop is in place and things like get_sidebar(). Compare whole pages to those of a working theme.

Wordpress admin area search bug "invalid post type"

I'm noticing a strange bug across several Wordpress sites and was wondering who else has experienced it - and how they solved it, ideally!
If I click All Pages and search for anything it works fine. If I try to search again from the results page, though, it spits out an "invalid post type" error.
The solution has been to click to view All Posts and start again - but there must surely be a fix?
Thanks!
G
For me the was issue was with the active theme, search in your functions.php code like 'pre_get_posts' , then you will see something like:
add_filter( 'pre_get_posts', 'my_posts' );
You must replace it with:
if(!is_admin()) {
add_filter( 'pre_get_posts', 'my_posts' );
}
For me it helped, but before this try to turn off plugins one by one to be sure that the problem was not from the plugins side.
It looks like conflict with some plugin or your theme: clean WordPress does not have this bug.
To debug, disable all plugins and check if it will be fine then. If it fixes your issue, start to enable plugins one by one to find "guilty" (you can use divide and conquer strategy to speed up this)
What do you have in url of page, when you see your error? It should have:
...&post_type=page&...
Do you have it?

Simple way to add "the loop" from Wordpress into any html/php template (that is not made for wordpress)

im looking easy steps for convert any html/php template into a very simple wordpress theme for personal use. I have a site, in there i want news at the begining using the wordpress interface, i worked a lot with wordpress and i made some themes, but modifing already made ones, so i didnt care a lot about the code.
So, lookin in internet i dint found a good step by step tutorial in order to create a simple theme in wordpress from 0. Remember that i dont need sidebars, widgets and soo, i only need "the loop", or, the last 3 post made.
It's as simple as installing wordpress correctly and then including the wp-blog-header file into your pages. Doing so will give you access to all of WP's functions.
require('/path/to/wp-blog-header.php');
$posts = get_posts('arguments');

Categories