Show the grandmother/father of the childpage

You need to look at get_ancestors() to get the top level parent of a page. Just a note, for reliability, use get_queried_object() (or even better $GLOBALS[‘wp_the_query’]->get_queried_object()) to get the current post/page object on singular pages, $post can be quite unreliable You can try the following in your shortcode: $post = $GLOBALS[‘wp_the_query’]->get_queried_object(); // Make sure the … Read more

Theme Appearance [closed]

every theme appears as basic HTML. So all the pictures, functionality, etc, do not appear When you visit any page which showcases a theme, or even check out the theme’s preview image (which is the image that shows up under the theme selection page in the back end), you will see an image of the … Read more

oEmbed work on localhost but not on distant server

It’s a missing configuration on the apache hosts file which cause troubles on serveur ‘self call’. For exemple, if serveur is using domain.com, I’ve a timeout when I typing curl domain.com with shh. Adding 127.0.0.1 domain.com in /etc/hosts file and it’s work !

Avoid loosing changes to theme

Your content (data) is stored in the database. If you don’t update the content, it will remain unchanged. Themes are mostly for data presentation (if there is no niche specialization on updating content). So, in the majority of cases, when you change the theme files, you don’t change the content itself. To be sure you … Read more

Output pure JSON wordpress

You will want to have your own url structure to output your “non html” output. Actually there are several ways, and it might be up to coding style preference to select one Add a Page and a template for the page that does what you need. You don’t have to output any html even in … Read more

Custom shortcode not being included in content paragraph [duplicate]

The ‘contact’ function should return a string instead of echoing. So the above, should look like: function contact() { $contact = get_field(‘contact’,options); return $contact; } add_shortcode(‘contact’, ‘contact’); Shortcodes are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output). See … Read more

How to display html code normally?

You have in the main editor, 2 modes: visual tab Text tab I think you have published your post (or page) under “Text” mode. What you have to do is to cut all the html code in “Text” mode tab. Then you have to set the editor in “Visual” mode tab, and to paste your … Read more

Show or hide custom fields by user’s role [frontend]

Yes, it is possible to hide or show custom fields by user’s role. Use current_user_can() for finding current user role. This function returns true if current user has capability or role. For example your current user is “wholesale” then you can use like this: <?php if( current_user_can(‘wholesale’)) { ?> // stuff here for wholesale <?php … Read more