How to check if feed URL was requested?

You have not specified exactly when your code runs but you can hook into “request” to check the requested page: add_filter( ‘request’, function( $request ){ if( isset( $request[‘feed’] ) ){ //This is a feed request } return $request; }); When the requested page is a feed $request, which is an array of query variables, will … Read more

Get wp_get_attachment_url outside of loop

if the result you’re looking for is a printout of the URL, like in your example, then this should work: $page_id = get_queried_object_id(); if ( has_post_thumbnail( $page_id ) ) : $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), ‘optional-size’ ); $image = $image_array[0]; else : $image = get_template_directory_uri() . ‘/images/default-background.jpg’; endif; echo $image;

How to display the page title/content in the Posts page?

I’m assuming the following: You’re using a Static Front Page You have a separate static page assigned to display the blog posts index You have created the home.php template file in your Theme The static page assigned to display the blog posts index is titled Blog You have added some post content to this static … Read more

Is there a default template file for child pages / subpages?

There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more

WordPress admin screen very slow / timing out when editing or adding a new page/custom post

This may not help any, but it can’t hurt to try it… Log into your server admin area, invoke the client interface for your database administration (e.g. phpMyAdmin), delete all the posts where their ‘type’ is marked as a revision, then compact the table. If you have thousands of pages, you might also have millions … Read more

Removing hierarchical pages in the permalink

I’d be curious if someone can find a better solution to this. Here’s what I came up with: function wpse_91821_flatten_page_paths( $wp ) { if ( false !== strpos( $wp->matched_query, ‘pagename=” ) && isset( $wp->query_vars[“pagename’] ) && $wp->query_vars[‘pagename’] && false === strpos( $wp->query_vars[‘pagename’], “https://wordpress.stackexchange.com/” ) ) { if ( !get_page_by_path( $wp->query_vars[‘pagename’] ) ) { $page = … Read more

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