Wordpress SEO - What are you looking for?

If you're looking for answers to SEO or wordpress related questions, type in a phrase and wait for hints or click enter! The results also show links to external sources.

161 articles in the database

Modification of WordPress search engine functionality

[ Article content is protected by Plagiashield ]

wordpress-search

Poniższe kawałki kodu modyfikują w konkretny sposób wyniki wyszukiwania w naszym WordPress.

Search for specific post types only

Place the code in the functions.php file

function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'typosta');
}
return $query;
}

add_filter('pre_get_posts','SearchFilter');

Instead of the "type" code in the 3rd line, type the slug of your desired post type

Search for posts only in specific categories

Place the code in the search.php file

amp;paged=$paged&cat=1,2,3"); ?>

In the third line of the code there are category IDs 1,2,3 - in this place we enter our category IDs that we want to include in the search

Changing the search URL

Place the code in the functions.php file

function search_url_rewrite_rule() {
if ( is_search() && !empty($_GET['s'])) {
wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redirect', 'search_url_rewrite_rule');

Replaces /?s=phrase with /search/phrase/

Limiting the number of retrieved items

Place the code in the functions.php file

function limit_posts_per_search_page() {
if ( is_search() )
set_query_var('posts_per_archive_page', 20);
}

add_filter('pre_get_posts', 'limit_posts_per_search_page');

Limit search results to 20 posts

Disabling the search completely

Place the code in the functions.php file

function fb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;

// to error
if ( $error == true )
$query->is_404 = true;
}
}

add_action( 'parse_query', 'fb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', 'return null;' ) );

And: https://www.seowordpress.pl/jak-automatycznie-przekierowac-wyniki-wyszukiwania-gdy-zawieraja-tylko-jeden-wynik/

Wojciech Wladzinski

O Wojciech Wladzinski

I have been dealing with SEO industry since 2008. At co day senior SEO specialist in the company Seogroup. I create and optimize large websites like and smaller websites online. I am particularly fond of the environment WordPresswhich, despite popular belief, is not just a blogging platform.
  • Internal Links and Sematics

  • Link building
  • Sematics
  • Link building has never been easier. Hundreds of link possibilities in one click.
  • See

[ Article content is protected by Plagiashield ]

SEMRush - the best tool for SEO and PPC.

en_USEnglish
Read previous post:
wordpress-facebook
Open Graph in WordPress

Today I'm going to show you how to easily implement Facebook Open Graph into a wordpress site for standard articles using a plugin like...

Close