New answers tagged

0

The answer was an admin filter on post_link which was building a custom permalink and returning false in some edge-cases, which caused the edit button to be hidden.


0

I realize this is an old question, however one thing I've noticed is no-one mentioned using get_queried_object(). It's a global wp function that grabs whatever relates to the current url you're on. So for instance if you're on a page or post, it'll return a post object. If you're on an archive it will return a post type object. WP also has a bunch of helper ...


0

Wordpress used the tagline as the slug for the home page and so it became part of the permalink for all the subsequent pages. And I realized that I am overthinking this.I was worrying that users would have to type in the whole string to get where they wanted to go and of course they would not. I will change the home page slug to something more relevant for ...


1

I ended up using wp_query instead because I couldn't make wp_get_recent_posts work no matter what I tried. For anyone who needs this functionality in the future, here's the code I used: // Get the ID of the current posts's term $terms = get_the_terms( $post->ID, 'comic-series' ); // Only get the parent term and ignore child terms foreach ( $...


0

Not sure if this is the only error, but watch out for WP functions that have get_ on the front, as they return the value in PHP without echoing it to the screen. The ones without will echo it. So probably you want: foreach( $recent_posts as $recent ){ ?> <a href="<?php the_permalink( $recent->ID ); ?>">...


0

First thing to check is make sure you visit permalinks page, or call the flush_rewrite_rules function once after you call add_rewrite_rules otherwise the rule will not get applied. So to restate your question, is it correct that you're trying to achieve rewriting this: example.com/project-centers/kitchen/x/y/z To this: eample.com/index.php?pagename=kitchen&...


0

It is normal behavior of WordPress to redirect users to 404 page when a post is not found. Both should have got redirected to 404 page ideally: domain.com/news-opinion/non-existing-url domain.com/non-existing-url It is strange that you are facing this issue. Would you mind trying the below steps (check the issue after each step): Change Permalinks to the &...


0

When registering the custom post types, set with_front to false: register_post_type( 'my_post_type', [ // ...etc. 'rewrite' => [ 'with_front' => false, ], ] ); The post type URL will then not include anything extra you've added in the Permalinks settings.


0

I do this directly on mysql table and works fine:


0

For multiple Custom Post Types adjust like this $query->set( 'post_type', array( 'post', 'custom1', 'page' ) && array( 'post', 'custom2', 'page' ) );


0

So to confirm, on a fresh Wordpress install with that setup /non-existing-url definitely returns 404, so it's not specifically the custom permalink that's the cause. It may be worth posting your .htaccess in case it's been modified. However I'd suspect that one of the plugins you have is helpfully adding this feature, and I'd suggest temporarily disabling ...


1

I was able to find the answer here: I had to create a custom permalink with the following value: /index.php/%postname%/


0

This is what worked for me (short and clean solution that includes the query strings in the URL too): $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ); The output URL will look like below http://sometesturl.test/slug1/slug2?queryParam1=testing&queryParam2=123 The solution was taken from here


1

When you register the CPT, use the rewrite argument to add the prefix. For example if your CPT is currently registered like this: <?php function wpse_create_cpt_testimonial() { $args = array( 'public' => true, 'label' => __( 'Testimonials', 'textdomain' ), // ... you probably have other arguments as well ); ...


2

A little more time searching around, and I found the answer... here it is in case it helps anyone else. In the function that creates the custom post type, I added this: $rewrite = array( 'slug' => 'results/testimonials', 'with_front' => true, 'pages' => true, 'feeds' =>...


1

This is how I use this, to only occur when my theme is activated, and only if there is no pre-existing setting saved (to not break something done before my theme is used). /* * Set permlinks on theme activate */ function set_custom_permalinks() { $current_setting = get_option('permalink_structure'); // Abort if already saved to ...


0

The default WP category is only set-up to show posts out of the box. You should be able to expand this by doing something like the below in your functions.php: // Order course archive and taxonomy views function adjust_main_query($query){ if ( ! is_admin() && is_category() && is_category() && $query->is_main_query() ) { ...


0

I've had issues when moving WP sites in the past. I'm guessing you have gone to settings > permalinks and clicked save to get your interior page links working? For image links, if you go to settings > media you should see only your thumbnail sizes. If you see a textbook that has a file path inside it, try editing that textbook to just read /wp-content/...


0

I realized that some php code changes the content of .htaccess file. The php folder was in a directory named 'securityl'. I've been removed that directory but whenever the website was refreshing the directory and also the php files inside it was recreating. In the end I discovered that some code in wp-include/load.php is creating the directory and I re-...


0

The same thing happen to me, it was due to some plugins I have installed, I removed all the recently added plugins, then everything worked fine. Still doesn't work then add this line: define( 'UPLOADS', 'wp-content/uploads' ); at the end of the wp-config.php file.


Top 50 recent answers are included