How to link to “most recent” document in the Media Library?

You could search the latest attachments like my example below. I searches for the string “newsletter”, and the first time it pops up in a filename, it writes a link. I’ve tried to make it easy to understand. $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 20, ‘post_status’ => null, ‘post_mime_type’ => ‘application/pdf,application/msword’ ) … Read more

Trailing slash at the end of permalink loads faster / better SEO?

If the permalink is to a file with an extension, no trailing slash is needed. http://www.domain.com/afile.html If the permalink is to a directory, a trailing slash is preferred. Otherwise, the server will respond with a redirect and the browser will have to add the trailing slash and make a second request automatically. http://www.domain.com/adirectory/ is served … Read more

Remove permalink settings in post for users

The default post types are post, page, attachment, revision, and nav_menu_item. Replace ‘post_type’ with ‘post’: add_action(‘admin_head’, ‘wpds_custom_admin_post_css’); function wpds_custom_admin_post_css() { global $post_type; if ($post_type == ‘post’) { echo “<style>#edit-slug-box {display:none;}</style>”; } } If you want to remove it for multiple post types (i.e. post, page, or any custom post types you might have), change line … Read more

How do I get all the URLs from my WordPress site?

I used the WooCommerce API and this code: <?php set_time_limit(0); // Include the client library require_once ‘class-wc-api-client.php’; $consumer_key = ‘XXXX’; // Add your own Consumer Key here $consumer_secret=”XXXX”; // Add your own Consumer Secret here $store_url=”http://www.example.com/”; // Add the home URL to the store you want to connect to here // Initialize the class $wc_api … Read more

How to create thousands of endpoints for a post or a page or a custom post type programatically?

It’s not clear from your question if you actually want the word/number structure or you merely use numbers to distinguish endpoints as different. Natively in WordPress there is no concept of endpoint with variable name. You can use add_rewrite_endpoint() to create a endpoint endpoint, which will match requests like …/endpoint/123, …/endpoint/124, and so on to … Read more

Permalinks: Page Not Found

Do you have mod_rewrite enabled? This sort of thing tends to happen when it’s not. At which point, you only have access to ugly permalinks (?p=N) or “almost pretty” permalinks (/index.php/slug). The latter uses pathinfo to get you the page you’re requesting instead. So I’d suggest double checking whether mod_rewrite is installed and enabled. If … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)