Adding a section in line at the end of the main navigation menu in php

https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/ function my_nav_menu_primary_navigation($items, $args) { $items .= ‘<li>Hello :D</li>’; return $items; } add_filter( “wp_nav_menu_{MENU SLUG}_items”, “my_nav_menu_primary_navigation”, 10, 2 ); find {MENU SLUG} EDIT: The “wp_nav_menu_menu-slug_item” filter runs at the end near the end of wp_nav_menu, $ items is a string containing the HTML extructura the menu and $ args are the arguments that you passed … Read more

Redirects based on a JSON file

The way I do it. Note there may be a more straightforward way. Step 1 Add a custom query_varlike this to record the redirect from/to variables function my_custom_query_vars($vars){ //this allows you to store custom variables with rediect_from and rediect_to in the url $vars[] = ‘redirect_from’; $vars[] = ‘redirect_to’; return $vars; } add_filter( ‘query_vars’, ‘my_custom_query_vars’ ); … Read more

“options.php” not found

Like @LupuAndrei said, we lack of details, especially the code where you call you form from. But I suspect, again like @LupuAndrei said, you might not be calling the settings_fields, do_settings_fields or do_settings_sections correctly. On the function where you build your form, try something like this <form method=”post” action=”options.php”> <table class=”form-table”> <?php settings_fields( ‘animated-settings-group’ ); … Read more

Function to insert missing image size attributes into img tags

function replaceImageMeta( $imagename ) { preg_match_all(‘/(alt|title|src)=(“[^”]*”)/i’,$imagename, $img);//var_dump( str_replace(“\””, “” , ( $img[2][0] ) ) ); list($width, $height, $type, $attr) = getimagesize( str_replace(“\””, “” , ( $img[2][0] ) )); $imgname = str_replace(“\””, “” , ( $img[2][0] ) ); return sprintf(‘<img src=”https://wordpress.stackexchange.com/questions/235051/%s” width=”%dpx” height=”%dpx” >’, str_replace(“\””, “” , ( $img[2][0] ) ), $width, $height); } So call … Read more

Add the_post_thumbnail_url to a shortcode in function.php

I think you’re just printing your function as a string, try concatonating: add_action( ‘woocommerce_product_meta_end’, ‘childReview’ ); function childReview() { global $post; echo do_shortcode(‘[cl-popup size=”l” title=”Click!” btn_label=”Headline” btn_bgcolor=”#006982″ btn_color=”#ffffff” overlay_bgcolor=”rgba(0,105,130,0.75)” title_textcolor=”#006982″ content_textcolor=”#006982″]<img src=”https://wordpress.stackexchange.com/questions/235313/” . wp_get_attachment_url ( get_post_thumbnail_id( $post->ID ) ) . ‘”/> [/cl-popup]’); }

Insert Content Before div#main from the functions.php File

The markup surrounding the content is not specified by WordPress, so there is no hook for that. But you can declare your own hook there. In your template file, write … <?php do_action( ‘before_content_container’ ); ?> <div class=”main”> <?php the_content(); ?> </div> <?php do_action( ‘after_content_container’ ); ?> … and then you can register a callback … Read more

Where to store credentials used in a function? [duplicate]

You could store it as variables $account_id = ‘your_account_id’; $password = ‘your password’; someFunction($account_id, $password); Or store it in {$table_prefix}_options table and retrieve it by get_option function $account_id = get_option(‘account_id’); $password = get_option(‘password’); someFunction($account_id, $password); You could save this values, for example from admin panel, by update_option function. Second option is better, because you can … Read more

Remove attachment page for audio media type only

You must use this function wp_check_filetype to check what is your media type $filetype = wp_check_filetype(‘image.jpg’); echo $filetype[‘ext’]; // will output jpg then you can have something like this $file_url = wp_get_attachment_url( $file_id ); $filetype = wp_check_filetype( $file_url ); switch ($filetype) { case ‘image/jpeg’: case ‘image/png’: case ‘image/gif’: return // do whatever you want break; … Read more