While working on a project I used the incorrect hook type add_action() which does not exist, yet there was no error notice and the correct result returned. I only realized it was wrong while searching for the method along with the $hook_name name in the package and it was not found, and when I checked the code reference page, it showed that it is add_filter(). Why does it still work?
I'm looking for a hand-coded solution to do the following: in some pages (so, not every page) I want to redirect the users NOT logged in to the standard login page: when they login, they are automatically redirected to the page where they were; same for some posts; I tested many free plugins but I was really not satisfied: some moves the login form in the protected page, some other lets you put a link to the login page. I'm …
I have problem with search in WordPress. I want to remove the "s" parameter in the URL. This is my URL: www.example.com?post_type=tour&s=&tour_location=70&tour_types=116&tour_month=144&tour_year=66 I want the URL to look like: www.example.com?post_type=tour&tour_location=70&tour_types=116&tour_month=144&tour_year=66 How do I need to modify my code?
I have a json schema code that I need to use it for all posts <script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://akhbarejadid.com/457881/" }, "headline": "title", "description": "this is a test description", "image": "https://media.imna.ir/d/2021/07/15/4/1713968.jpg", "author": { "@type": "Person", "name": "Javad" }, "publisher": { "@type": "Organization", "name": "Akhbarejadid", "logo": { "@type": "ImageObject", "url": "https://akhbarejadid.com/wp-content/uploads/2021/05/logoakhbarejadid.png" } }, "datePublished": "2022-03-01", "dateModified": "2022-03-16" } </script> Can I use wp codes like the_title(); or the_author(); or the_content(); for this json …
I am trying to remove menu from the admin panel my code works as it removes some pages but i can't remove the following. admin.php?page=ot-theme-options admin.php?page=ot-settings admin.php?page=yith_woocompare_panel add_action('admin_menu', 'remove_admin_menu_links'); function remove_admin_menu_links(){ $user = wp_get_current_user(); if( $user && isset($user->user_email) && '[email protected]' == $user->user_email ) { remove_menu_page('tools.php'); remove_menu_page('options-general.php'); remove_menu_page('plugins.php'); remove_menu_page('users.php'); remove_menu_page( 'themes.php' ); remove_submenu_page( 'themes.php', 'widgets.php' ); remove_menu_page( 'wpcf7' ); remove_menu_page( 'ot-theme-options' ); // Doesn't work remove_menu_page( 'ot-settings' ); // Doesn't work //echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>'; …
Hi I am building a news website. I am trying to automate it. News url (metabox) Title Content area Image (featured image option on wordpress) When paste the site url I would like the other metabox to pull the data from the source http://www.bbc.co.uk/news/technology-34527439 I want title and description to pulled form bbc website News url: http://www.bbc.co.uk/news/technology-34527439 Title: Should be fetched from <title> Content area: should be from <meta name="description".> Image: Should be first image on the content I see …
Looking through the Wordpress documentation, it says that is_page_template() compares against a "template name", if one is provided. I have a template stored in page-homepage.php called Homepage: /* * Template Name: Homepage * Description: The template for displaying the homepage */ And I have some code I wish to run in my functions.php when I'm using that template: if (is_page_template('Homepage')) { ... But it isn't being triggered when I'm on a page which uses that template. When I look at …
So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed. But if we turn to the Codex docs for get_posts we see no mention of posts_per_page, instead citing numberposts. In post.php we see what's happening: numberposts is set up as a default (5), but then copied to posts_per_page (unless posts_per_page is set in the args). So my question is really quite pedantic, but I'm looking …
I wrote a function in my theme's functions.php and am attempting to register it with add_shortcode() as shown in the Codex: <?php /** * theme's functions.php */ namespace MyNamespace; //[foobar] function foobar_func( $atts ){ return "foo and bar"; } add_shortcode( 'foobar', 'foobar_func' ); However this does not work and a post containing [foobar] simply renders "[foobar]" as text instead of being replaced by the handler function's return value. My guess is it has something to do with my functions.php being …
I need to see if an option, and if does, get the value. If not, I need to add it. The Codex provides: <?php $option_name = 'myhack_extraction_length' ; $new_value = '255' ; if ( get_option( $option_name ) != $new_value ) { update_option( $option_name, $new_value ); } else { $deprecated = ' '; $autoload = 'no'; add_option( $option_name, $new_value, $deprecated, $autoload ); } Which supposedly updates the option name myhack_extraction_length with the value 255. If the option does not exist then …
I am looking for a approach to add multiple images option under the Feature image section in wordPress custom post type. I will integrate/implement these images on single.php file where I want to show the slider images. I want to do it using Codex / coding approach, Please NO PLUGIN. Any Idea/help will be appreciated.
So like WP must load series of files from, index.php -> ... -> wp-header.php -> ... ->functions.php ...and so on upon execution. Also there must be a similar flowchart for functions callings, conditionals and such during the execution. Is such a flowchart(s) available anywhere?
How to create a tag and category for plugins just like the function shown below performs for pages? function add_categories_to_pages() { register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'add_categories_to_pages' ); function add_tags_to_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); } add_action( 'init', 'add_tags_to_pages'); I tried to manipulate for category but with no success
I am trying to find the list of available values for name in the search to filter results. So far I have found name="s" is the default name="cat" is for categories and name="post_type" is for post types. I am relatively new to WP and I am finding it hard to know how to find details like this. Can you please show me where in the codex these options came from? Other resources are appreciated as well.
I have a WordPress form plugin and I use media_handle_upload to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that: The HTML of the form field is: <input type="file" name="my_file_upload" id="my_file_upload"> And the php code was: $attach_id = media_handle_upload( 'my_file_upload', $post_id ); if ( is_numeric( $attach_id ) ) { update_post_meta( $post_id, '_my_file_upload', $attach_id ); } And everything was work perfectly. Now I am …
I am tring to implement custom filter for The Event Calendar. I have used this code $args = array( 'post_type' => 'tribe_events', 'meta_key' => '_EventStartDate', 'meta_query' => array( array( 'key' => '_EventStartDate', 'value' => array( $start_date, $end_date ), 'compare' => 'BETWEEN', 'type' => 'DATE' ) ), 'category__in' => array( 2, 6 ) ); $query = new WP_Query($args); It will return blank post
when i go to wp customizer then i want edit the name popular and cat_id =21 <div class="p_list"><h2><span>popular</span></h2> <?php $first = true; ?> <?php $cat_id = 21; $latest_cat_post = new WP_Query( array('posts_per_page' => 4, 'category__in' => array($cat_id))); if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post(); ?>
Compare the following two links: https://codex.wordpress.org/Function_Reference/get_next_post https://codex.wordpress.org/Function_Reference/get_previous_post The get_previous_post function doesn't have the last $taxonomy parameter, while get_next_post has it listed. I followed those instruction literally, which caused my get_previous_post to break. When I noticed the difference between the two functions, I tried specifying the taxonomy in my get_previous_post function, which fixed the problem. Is this a mistake in the Codex for get_previous_post?
Im using the Following Code in search.php <?php if (have_posts() && strlen( trim(get_search_query()) ) != 0 ) : while (have_posts()) : the_post(); ?> <?php endwhile; else:?> <b>No results match your search.</b> <p>For Accurate results, Please Search the Model Number of the device or the Brand Name.</p> <?php endif; ?> <div class="navigation"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?> <?php } ?></div> Functions.php: function SearchFilter($query) { // If 's' request variable is set but empty if (isset($_GET['s']) && empty($_GET['s']) && $query->is_main_query()){ …
I have read the WordPress Codex on add_filter and apply_filter countless times, but it wasn't until reading woocommerce source code today that something clicked in the way that maybe I don't understand the way apply_filter works or maybe I don't quite understand how it creates a new hook and when/where is the function defined for the new hook? Review the wordpress codex again CODEX: apply_filters( string $tag, mixed $value ) Call the functions added to a filter hook. The callback …