Display WordPress Post on A Different Site

TBH I think its a bit late to answer this question, But here it goes anyways. All you need to do is format some JSON Data Step 1: Get the JSON domain.com/wp-json/wp/v2/posts?per_page=1&_embed&taxonomy Change per_page=1 to the number of posts you’d like to query If you want to filter the post according to tags or categories … Read more

Count foreach and display in menu php

You’re incrementing $count but I see you’re referencing $counter. Not sure if those are different but here is a version that uses the same variable in all those places. $counter = 0; //Hier ist der Count-Begin-Foreach foreach ( $bookmarks as $bookmark ) : if ( get_post_status( $bookmark->post_id ) !== ‘publish’ ) { continue; } // … Read more

preg_replace on all HTML content in WordPress

WordPress doesn’t have a “final output” filter. Just google search I found a interesting answer from Stack Overflow. All credits go to @kfriend More Details (SO question link) : WordPress filter to modify final html output <?php /** * Output Buffering * * Buffers the entire WP process, capturing the final output for manipulation. */ … Read more

Can we stop session reset if page reloads?

WordPress doesn’t use PHP sessions. If you tried stating a session in your custom-written code, it’s not going to work as you’d hope. There’s a plugin which will enable all normal session use: https://wordpress.org/plugins/wp-native-php-sessions/ But, depending on what exactly you’re trying to achieve, you may prefer to keep things clean/do it the WordPress way and … Read more

Removing sidebar on category pages

category page flow (bottom to top) is like this: category-slug.php category-ID.php category.php archive.php index.php so you can not create compulsory category.php. open your current theme archive.php. and edit this code. <?php if( !is_category() ){ get_sidebar(); } ?>

Disable Content Editor for Specific Pages

Your if condition is wrong and generates a syntax error. You need an logical operator to check for multiple conditions. Therefore your code should look like the following: if ( $template_file === ‘page-custom-one.php’ || $template_file === ‘page-custom-two.php’ ) { remove_post_type_support( ‘page’, ‘editor’ ); } You could also check for multiple values with the in_array function … Read more

How to use AJAX in WordPress in MYSQL query?

In WordPress it little bit complicated then default way to handle ajax form data. odify your js code like this. function ajaxSubmit(e){ // prevent the default action. e.preventDefault(); var myform= jQuery(this).serialize(); jQuery.ajax({ type:”POST”, // Get the admin ajax url which we have passed through wp_localize_script(). url: ajax_object.ajax_url, action: “submitAjaxForm”, data: myform, success:function(data){ jQuery(“.records”).html(data); } }); … Read more

How to modify mobile nav menu text in theme

You can leverage the use of the gettext filter to change the text. Add this code to your child theme’s functions.php or to a plugin: add_filter(‘gettext’, ‘wpse248225_change_text’, 20, 3 ); function wpse248225_change_text( $translated_text, $untranslated_text, $domain ) { if ( NECTAR_THEME_NAME !== $domain ) { return $translated_text; } // Make the changes to the text switch( … Read more

PHP error with a shortcode: “no suitable wrapper” for file_get_contents

Use the HTTP API: $http = wp_remote_get( ‘https://en.wikipedia.org/w/api.php?action=query&titles=Test_article&prop=revisions&rvlimit=1&format=json’ ); if ( ! $body = wp_remote_retrieve_body( $http ) ) return; if ( ! $data = json_decode( $body, true ) ) return; $date = new DateTime( $data[‘query’][‘pages’][‘746140638’][‘revisions’][0][‘timestamp’] ); return $date->format( ‘m-d-Y’ );