get_page_by_title() not returning anything [closed]

You are missing the second parameter in get_page_by_title. See get_page_by_title() reference. When you are testing without explicitly specified $output and $post_type, this function returns the post of type ‘page’ object by default. So you have to return $page->post_parent for patient’s parent page ID: add_filter(‘gform_field_value_parent_id’, ‘parent_id’); function parent_id() { // three parameters here $page = get_page_by_title(‘TESTID’, … Read more

Enable comments for post with comments meta box removed

Here’s what I ended up with. For limited access users, I set comments on when the post guid is empty. Otherwise, I completely remove the comment_status field for those users. That defaults new posts to comments enabled, prevents limited access user edits from switching them off, while allowing admins to override the setting on/off. add_filter( … Read more

Custom Taxonomy Breadcrumb Navigation

Using your method, I’ve edited it a bit to make it more viable. Here’s the code, below I’ll explain. <ul> <li><a href=”https://wordpress.stackexchange.com/questions/149424/<?php echo home_url(); ?>/projects”>Projects</a></li> <?php $term = get_term_by(“slug”, get_query_var(“term”), get_query_var(“taxonomy”) ); $tmpTerm = $term; $tmpCrumbs = array(); while ($tmpTerm->parent > 0){ $tmpTerm = get_term($tmpTerm->parent, get_query_var(“taxonomy”)); $crumb = ‘<li><a href=”‘ . get_term_link($tmpTerm, get_query_var(‘taxonomy’)) . ‘”>’ … Read more

How can I programmatically save data into custom fields that contain serialized data?

For serializing and unserializing Data in WordPress, you can use maybe_unserialize and maybe_serialize. If you want to handle the data and add/change values, you could use something like this: $metaarray = maybe_unserialize(get_post_meta($post_id,’_ait-dir-item’,TRUE)); //now $metaarray has an array, if it is serialized. If not, $metaarray has a string. if(is_array($metaarray)){ $metaarray[‘mynewfield’] = ‘Some text i need to … Read more

Single page template for custom post_type

I had the same problem. Why WordPress doesn’t automatically use the custom single.php template is above me. That aside, here is the code I’m using to force my CPT to use my custom single.php. Just change the CPT and template name to suite your needs. <?php /* Information Posts Template selection – a single.php just … Read more

How to show particular category all post in custom single file

Using The Loop with the required arguments should list all the posts. An Example: $temp = $wp_query; <?php $type=”post_type”; $args = array ( ‘post_type’ => $type, ‘post_status’ => ‘publish’, ‘paged’ => $paged, ‘posts_per_page’ => 20, ‘ignore_sticky_posts’=> 1 ); $temp = $wp_query; // assign ordinal query to temp variable for later use $wp_query = null; $alt … Read more

Used with meta_query in query_posts works slowly

When you have a few thousand entries and use post_type in combination with meta values, the MySQL query starts running very, very slowly because it seems to do a full table scan on the wp_postmeta table. The most direct solution is to add an index on the wp_postmeta table to avoid the full scan. This … Read more