Preventing Canonical Redirect for CDN

This can not work in the way you want. If wordpress is on example.com then all the auto generated links will point to example.com even for pages that are on the CDN under the www.example.com domain. This will result that after the first page being served from the CDN many other pages will be served … Read more

How to add PHP pagination to wordpress

you can use paginate_links() from wordpress core API, its make more easily to paginate your custom query. And you dont need to make another query to get all users count. <?php $users_per_page = 10; // total no of author to display $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; if( (int)$paged === 1 ){ $offset = … Read more

How do I include an external PHP file in a subdir WordPress install?

In you case I’d edited my wp-config.php, and just after if ( !defined(‘ABSPATH’) ) define(‘ABSPATH’, dirname(__FILE__) . “https://wordpress.stackexchange.com/”); I’d added $path = explode( basename( dirname(__FILE__) ), ABSPATH ); define( ‘MYSITEROOTPATH’, $path[0] ); after that, everywhere I need, I’d used // file.php is name of a file in root directory include( MYSITEROOTPATH . ‘file.php’);

How to access the WordPress DB from a plugin file

If you plan to share/sell your plugin I strongly suggest don’t load your plugin directly. That because to load WordPress you need to load the bootstrap file, that is /wp-load.php so, you should put in your embed-video.php something like: require ‘/wordpress/path/wp-load.php’; Do you notice the problem here? The /wordpress/path/ part is different for user to … Read more

Add # to submenu URLs automatically

This ended up doing the trick. function auto_hashtag( $menu_item ) { if ( ! is_admin() && $menu_item->post_parent > 0) { // url $url = $menu_item->url; $menu_item->url = preg_replace(‘!/([^/]+)/$!’, “/#\\1”, $url); } return $menu_item; } add_filter( ‘wp_setup_nav_menu_item’, ‘auto_hashtag’ );

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