Articles of functions

radio button is checked but display not check

im trying to save different value of radio buttons on same name, it works and was able to make checked appear if the correct value is saved. As you can see on the screenshot ABOVE (which is taken on view-source:), it the correct selected input is CHECKED already however even if it’s check you can […]

img width and height attributes being set by get_the_post_thumbnail

I’m working on a custom theme that I’ve inherited to maintain. At the top of the homepage there is a header area with some images generated by get_the_post_thumbnail. The call to get_the_post_thumbnail outputs img objects that are set to a specific width/height by their html attributes. Here’s the code and output: Inside a loop <?php […]

Toggle Sidebar Display

I’m developing a WordPress theme that allows users to toggle the visibility of the sidebars using Javascript in the same way that wikis allow users to show or hide a table of contents. When a user clicks the link to hide a sidebar I have a toggle() javascript toggle function that sets the visibility of […]

How to insert a text in all pages and posts before or after specific places?

I have this simple code below: function func1() { echo “this is amazing”; } add_action(‘reko_hook’,’func1′); Now, I know that I could use reko_hook(); either inside index.php or page.php where I want, but I was wondering if there are more pre-defined hooks such as ‘init‘. For example, I could do add_action(‘init’,’func1′); but it will echo this […]

Is It wrong to use oop approach on functions.php?

I’m building a theme, and I’m using an oop approach, nevertheless all themes source code that I have seen until now, make use of procedural approach, so they write this sort of code: If ( ! function_exists( ‘my_theme_function’ ) ) { my_theme_function() { // code function here } } So what is the ideal methodology […]

How to find the source of the text for wordpress website? I want to change that text

I have following code, which is generating the the text on the website. code resides in front-page.php file in the theme folder. <p class=”excerpt”> <?php $theExcerpt = get_the_excerpt(); $tags = array(“<p>”, “</p>”); $theExcerpt = str_replace($tags, “”, $theExcerpt); echo $theExcerpt; ?> </p> Let me know if you want more information. Thank you.

How to preserve edits to Name or Slug of term when using wp_update_term on save?

I am trying to insert content into a term’s description field on save. // insert stuff into description field of taxonomy function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){ // only insert content on certain taxonomies if ( $taxonomy === ‘some_custom_taxonomy’ ){ // unhook this function so it doesn’t loop infinitely remove_action(‘edit_term’, ‘insert_taxonomy_content’); $content = “Some Content”; […]

how to get permalink structure with php

I need to make if statements for every permalink structure, so I need to know if there is a function that returns to me the actual selected permalink structure by the user. To make it simple all I need to know is if this permalink:; a condition will apply else if this structure […]

Calculations in functions.php

I’ve created an invoice theme for myself and I’m trying to get the invoice total in a custom column. I’ve tried adapting the code I’m using within the template page to display this in the functions.php file but it’s not working. I’m getting an operand error where my multiplication operand is and I don’t know […]

Debugging with functions.php

I’m trying to check the output of a variable in my functions.php file that runs after a new woocommerce order. The code will get the order time from a new order and store it in a variable for me to use elsewhere the code being: $meeting_time = wc_get_order_item_meta($order_id, ‘Time’); print_r($meeting_time); I’ve tried a few ways […]