url_to_postid returns 0

when you are at the post URL, you don’t need to work with referer (which is not reliable moreover) but with $GLOBALS[“post”] because you are in the PHP code which generate the page then you can have the post ID with that : $post_id = $GLOBALS[“post”]->ID;

How to reference PHP in Javascript

To answer the question, no: It’s not an issue with formatting, it’s as jdm2112 explains the matter. You can, however, “send” the variable , or have it plucked from the server, either via an Ajax call as jdm2112 suggests or as set by wp_localize_script(). Which you use will likely depend on what the script does … Read more

WordPress homepage setup not working on first load

I would say that the parsing of the “hello world” post is due to the site home url being the default for new site initially. So after the theme functions.php file has run the first time on the first time the site is called your settings are updated by your code, then any future landing … Read more

Add New Text Box To WordPress Twenty Seventeen Header

That works if you put your code in header.php, copied in the childtheme, after the line: <header id=”masthead” class=”site-header” role=”banner”> My html code is: <div class=”logo-right-text”> <span style=”font-size: 14px; font-weight: bold; color: #555;”>1800-123-456-22</span> <div class=”clear” style=” height:3px;”></div> <span style=”font-size: 14px; font-weight: bold; color: #555; “>[email protected]</span> </div> And CSS: div.logo-right-text{ margin: 0px 10px; } div.logo-right-text { … Read more

Alphabetically Ordered Category in WordPress

WordPress is a pretty well documented CMS which means at you can probably google the function name and find the answer based on parameters. If we look at the documentation of wp_list_categories() we see it has both an order and orderby which we can pass in. So, to order the categories in an alpha-numeric list … Read more

Notice: Trying to get property of non-object

This code tries to retrieve a post instance, but it is failing for some reason. On top of my head I don’t think this should ever happen within normal operation of menus. I would suspect that menu structure is somehow corrupt. Without diving into development side of it, an attempt of easy fix might be … Read more