is_singular() not working if called via callback function of admin-ajax.php

An AJAX request is a new request to the server, and it is a request to admin-ajax.php. That is not a single post page. Any logic that depends on is_single() or any other page level template tags like it, won’t work. If your AJAX callback needs that sort of information you must pass it to … Read more

Get Content From Blog Page

You are using get_the_content() wrong, it can’t take a ID, which is what get_option(‘page_for_posts’) does return, and generally gets the content of the current post inside the loop, in which it has to be used. To get the actual content of that page you can do: $page_for_posts_id = get_option( ‘page_for_posts’ ); $page_for_posts_obj = get_post( $page_for_posts_id … Read more

How to embed page content in a blog post

Create a shortcode to embed the content. This will always be synchronized. Sample code from an older project. Just updated. ๐Ÿ™‚ GitHub: https://gist.github.com/3380118 ยท This post in German (auf Deutsch) on my blog. <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Embed Post Shortcode * Description: Embed any page, post or custom … Read more

Show Default Editor on Blog Page ( Administration Panel )

In WordPress 4.2 the editor was removed on whichever page was assigned to show Latest Posts for whatever reason. The following function below ( original solution found here by crgeary ) will re-add the editor and remove the notification: You are currently editing the page that shows your latest posts. Here’s some information on the … Read more