only last option from theme options is being saved to the DB

I have this admin page functions where I am trying to prompt the admin for some text data.

the problem that is only the last field is being saved and existed ain the DB, the top ones do not exist in the DB at all.

adding options to admin page:

 register_setting( 'top-data-group', 'yourLogo');  register_setting( 'card1-group', 'card1_text');  register_setting( 'card4-group', 'card4_text');     add_settings_section('top-options', 'Top Information', 'top_options', 'top-data' );   add_settings_section('card1', 'Card 1', 'card1_options', 'top-data' );   add_settings_section('card4', 'Card 4', 'top_options', 'top-data' );    add_settings_field('yourLogo', 'Logo Image URL:', 'yourLogoImage_callback', 'top-data', 'top-options'  );  add_settings_field('card1_text', 'card 1 text:', 'card1_text_callback', 'top-data', 'card1'  );  add_settings_field('card4_text', 'card 4 text:', 'card4_text_callback', 'top-data', 'card4'  ); 

callback functions:

 function card1_text_callback (){     $  preText =  esc_attr( get_option('card1_text'));      echo ' <input type="text" name="card1_text" placeholder="card text" size="50" value="'.$  preText. '" > ';  }   function card4_text_callback (){     $  preText =  esc_attr( get_option('card4_text'));      echo ' <input type="text" name="card4_text" placeholder="card text" size="50" value="'.$  preText. '" > ';  }  function yourLogoImage_callback (){     $  preText =  esc_attr( get_option('yourLogoImage'));      echo ' <input type="text" name="yourLogoImage" placeholder="your Logo Image URL" size="50" value="'.$  preText. '" > <p> use external or internal image url , preferred (300 * 50 px) </p>'   ;  } 

the form page:

<h1> Top Section </h1> <?php settings_errors(); ?>   <form action="options.php" method="post" >       <?php        settings_fields('top-data-group');     do_settings_sections('top-data');      settings_fields('card1-group');     do_settings_sections('card1');      settings_fields('card4-group');     do_settings_sections('card4');      submit_button('save', 'primary sub-button', 'submit', true);    ?> </form> 

only last option is being saved to the db, top ones are all empty.

Form Submission Not Working In Custom Theme

I have a php contact form on a couple of static sites, and I’ve cut and pasted the form itself and the php code into a WordPress site.

For some reason the form isn’t working? Is there something extra I need to do with forms on a WordPress site (it’s a custom theme and the code is on a contact page). The contact form information is (theoretically) being sent to an email address when submitted.

When I fill in and submit the form it just throws a 404 page error. The php is placed at the top of the page below the get_header(); function.

Any tips or pointers would be hugely appreciated.


<?php   if($  _POST['submit']) {      if(!$  _POST['name']) {         $  error="<br>- Please enter your name";     }     if(!$  _POST['email']) {         $  error.="<br>- Please enter your email";     }     if(!$  _POST['telephone']) {         $  error.="<br>- Please enter your telephone number";     }     if(!$  _POST['message']) {         $  error.="<br>- Please enter your message";     }     if(!$  _POST['checkbox']) {         $  error.="<br>- Please confirm you agree to the Privacy Policy";     }      if ($  error) {         $  result='<div class="alert error">Whoops, there is an error. Please correct the following: '.$  error.'</div>';     } else {         mail("", "Contact Message", "Name: ".htmlspecialchars($  _POST['name'])."         Email: ".htmlspecialchars($  _POST['email'])."         Telephone: ".htmlspecialchars($  _POST['telephone'])."         Company: ".htmlspecialchars($  _POST['company'])."         Budget: ".htmlspecialchars($  _POST['budget'])."         Message: ".htmlspecialchars($  _POST['message']),         "From:\r\n"     );          {             $  _POST= array();             $  result='<div class="alert thankyou" role="alert">THANK YOU! WE\'LL BE IN TOUCH SHORTLY...</div>';         }          $  headers = "From:\r\n";     } } ?> 


<form id="contactform" method="post" action="#section-2">     <?php echo $  result; ?>     <div class="form-row-1 js-st">         <input id="name" type="text" name="name" placeholder="Name" value="<?php echo $  _POST['name'];?>">         <input id="email" type="email" name="email" placeholder="Email Address" value="<?php echo $  _POST['email'];?>">     </div>     <div class="form-row-2 js-st">         <input id="telno" type="text" name="telephone" placeholder="Telephone Number" value="<?php echo $  _POST['telephone'];?>">         <input id="company" type="text" name="company" placeholder="Company [optional]" value="<?php echo $  _POST['company'];?>">     </div>     <div class="form-row-3 js-st">         <textarea id="project-details" name="message" placeholder="Tell us about your project"><?php echo $  _POST['message'];?></textarea>     </div>     <div class="form-row-4 js-st">         <input id="budget" type="text" name="budget" placeholder="Budget" value="<?php echo $  _POST['budget'];?>">         <p class="budget-subline tl ">*We recommend putting in an approximate budget</p>         <input id="privacy-checkbox" type="checkbox" name="checkbox"><label id="privacy-label" for="privacy-checkbox">I agree to the <a href="./privacy.php">privacy policy</a></label>     </div>     <input class="js-st" id="formsubmit" type="submit" name="submit" value="SUBMIT"> </form> 

Where can I find the “add_action()” inside a theme?

I’m developing a WordPress plugin for a site that is using the theme ColorMag. The plugin uses the_content() to insert some content in a page. When I put the plugin in other test site, the content is showing ok, but with the ColorMag theme the content is showing in the right place but also two more times at the start of the page.

Looking at the code I’ve found that this repeated content is made inside “header.php” in the line <?php do_action( 'colormag_before' ); ?>. But I can not find where is the corresponding add_action() so I can not modify it.

Where can I find the add_action()?


is_admin() returns false for theme customizer, how to check for it?

As I strive to get rid of jQuery, I force it off otherwise, some plugins will always add it back if enqueued.

I still want it for the admin as it’s required and performance is less of an issue. Nevertheless, id_admin() function returns false when using the theme customizer.

function my_theme_remove_jquery(&$  scripts) {     // here if have to check for server url to add jQuery when customizing the site,     // otherwise it's not loaded and customizer won't work properly     if (is_admin() || strpos($  _SERVER['REQUEST_URI'], 'customize_theme')) return;      $  scripts->remove('jquery'); } add_filter('wp_default_scripts', 'my_theme_remove_jquery'); 

Is there some other way I could detect the customizer or is this good enough?

twentysixteen child theme – responsive menu – ham icon button not working – Cannot read property ‘classList’ of null

I am trying to convert this site into twentysixteen child theme. It appears that /js/menu.js in my child theme is not working as nothing happens when the ham icon button is clicked (pls.see my site link above to check correct behavior). On inspecting via Google Chrome Inspect I am getting the following errors:

Uncaught TypeError: Cannot read property ‘classList’ of null at mediaqueryresponse (menu.js?ver=5.3.2:19) at menu.js?ver=5.3.2:10 at menu.js?ver=5.3.2:31 mediaqueryresponse @ menu.js?ver=5.3.2:19 (anonymous) @ menu.js?ver=5.3.2:10 (anonymous) @ menu.js?ver=5.3.2:31

Any advice is appreciated

header.php in child theme

<header class="header" id='myTopnav'>  <?php  wp_nav_menu(              array(                   'theme_location'=> 'topnav',                   'container' => 'nav',                   'menu_class' => 'topnav',                   'menu_id'    => 'myTopnav',                   )  );?>  <button class="ham-icon"><span class="fa fa-bars fa-2x"></span></button>  </header> 

/js/menu.js in child theme

(function () {   var mql = window.matchMedia("screen and (max-width: 960px)");   //detect media query    var navTop = document.querySelector(".header");   //return first element within the document that matches .header    var toggle = document.querySelector(".ham-icon");    mediaqueryresponse(mql);   //ensures that addListener function is executed when the page loads, by default addListener only fires when state of the window changes   mql.addListener(mediaqueryresponse);    function mediaqueryresponse(mql) {     if (mql.matches) {       toggle.addEventListener("click", clickMenu);       //if media query matches, execute click or clickMenu event     } else {       navTop.classList.remove("responsive");       //otherwise remove .responsive       toggle.removeEventListener("click", clickMenu);       //and remove EventListener     }    }    function clickMenu() {     navTop.classList.toggle("responsive");   }  })(); 

WordPress Theme Shop

This website is made for WP themes shop, or just sharing with the community. There are 1 theme that can be downloaded on the web.

The idea for those who want to continue, by direct selling the themes or by giving free themes that can be easier to get traffic, then promote products related to themes and premium plugins from ThemeForest or other providers and get affiliate commissions, affiliate hosting, or selling web design services.

The sale includes:
– Main website
– 1 theme ready to…

WordPress Theme Shop

Remove pre and code tags from WordPress theme

WordPress has added both <pre> and <code> tags to my PHP embedded in a post.

Here’s an example

<pre><code>register_taxonomy( 'Books', 'post',  array(     'label' =&gt; __( 'Books' ), ) ); 

And here’s what it should look like

register_taxonomy( 'Books', 'post',  array(     'label' => __( 'Books' ), ) ); 

I know the arrow > symbol is changed by the code in my theme but the <pre> and <code> tags are added by WordPress.

Does anybody know a solution which would enable me to remove these tags so the code displays correctly?

A little stumped – first WordPress theme

I am going through an online Udemy course alongside it I’m building my own little website.

The website has 4 pages 1 of them a front page that I’ve created front-page.php and the rest of the pages will be using the page.php template but different content embedded in them.

My plan is to have the page.php call the relevant content based on the page-id for instance for a warranty page the code would look like this.


get_template_part( 'template-parts/content', get_the_ID()); 

//getting the content from templates based on ID?>


get_template_part( 'template-parts/content', get_the_title()); 

//And get the content based on the title of the page

so I guess my question is, is this the correct way of doing this or how else more efficient way would you go about doing this?


Genesis Child Theme – Customize body

So I created a custom post type and I’ve also created a custom page called page-profile.php that follows the WordPress templating.

Here is the code inside page-profile.php:

<?php  $  args = array(     'post_type' => 'profile', // enter custom post type     'orderby' => 'title',     'order' => 'ASC',     'posts_per_page' => '4', ); $  loop = new WP_Query($  args);  get_header(); // displays header get_sidebar(); get_footer(); //displays footer 

So the header, footer and sidebar all are being called in.

How can I target the red box and create templating where I would like to show the title and thumbnail?

enter image description here