I am trying extremely hard to show a next & previous button regardless if it is active on my wordpress theme. I cannot seem to figure out a way to make it work. I am trying to do this: http://www.kinocreative.co.uk/hints-and-tips/wordpress-nextprevious-post-navigation-with-images-and-inactive-links/ exactly but for my category archive page. I have tried using something like:
<?
echo 'Previous';
echo 'Next';
?>
But that doesn't work to go to the next/previous page of categories.
While this may not be the case for you, I have found through the different themes I've implemented, that not all pages support the next and previous buttons being added. There is a certain way the posts are requested from the database that doesn't always give you what you want.
If you have followed the guides out there (like I did), it's possible that page in particular just won't support it. I know it's not the answer you're looking for, but take it into concideration instead of wasting all your time. You could always edit the theme entirely to allow a feature like this. Take a look at editing how your theme is generating posts altogether, instead of just trying to add the buttons.
These may be handy:
http://codex.wordpress.org/The_Loop
http://codex.wordpress.org/Template_Tags/get_posts
Related
I've been trying to conduct some research on this issue,
So building a shortcode for example lets say I have this function
function example_shortcode($content, $atts){
$disclaimer = $atts['disclaimer'];
return "<div>$disclaimer</div>";
}
add_shortcode("example_shortcode","example_shortcode");
buy having the
$content //variable passed to the example_shortcode();
This sort of works for shortcodes as long as it is output by the standard
the_content(); //function through the wordpress wysiwyg
But lets say I call the function into a custom-template.php file and add that template to the page editor attributes for WordPress instead of using the WYSIWYG, then the shortcode content wont appear when doing a search on the front end of the site. To me I feel like wordpress should process this this more intelligently in the future especially since using custom templates loaded through wordpress.But for example
i.e. example.com/?s=test
What concept do I need to start understanding next here, I know if the shortcode is processed through the_content(); function it will sort of work as mentioned earlier,
But really the second part of my question, is just dealing with custom-template.php files using Advanced Custom Fields being output into custom_functions(); then being called into custom-templates.php which are then being loaded through the page attributes of the wordpress page editor, my content and everything works just doesnt show up in search results on wordpress frontend site itself?
I've searched the internet for this issue many times, doesn't seem like many people care about this issue, as I can't find much research or the research is tough to find, or I'm searching incorrectly.
Can anyone start pointing me in the right direction, and new tips on research for this topic.
Thank you all for any comments and advice.
Ive conducted countless hours of research, along with the Plugin Author of Relevanssi Better Search for Wordpress.
So I wanted to share the solutions here.
https://wordpress.org/support/topic/search-not-including-php-hard-coded-content/#post-14432554
This Stack Overflow question is also related to this question here
Actually I have changed some code in WordPress Store Locator. I want it to remain when plugin will update. So I want to create a child plugin for that. Any ideas on how I could manage it?
This varies plugin to plugin, and it sometimes isn't even possible, other times plugins have documentation to extend them easily (such as WooCommerce and Gravity Forms). Some of them create Action Hooks with do_action() that let you extend the functionality easily. A common example is updating a post after a Gravity Form is submitted with their gform_after_submission hook.
Effectively, it depends on what you want to do, and how the plugin implements the functionality you want to change. If they add text with a Closure or Anonymous Function, it will be harder to modify said text, and you may have to look at something strange like doing a run-time find and replace using Output Buffering, typically on the template_redirect hook.
If you want to remove something a plugin does, you can often unhook it with remove_action. This can be a bit tricky depending on how the plugin is instantiated, sometimes its as simple as:
remove_action( 'some_hook', 'function_to_remove' );
Other times it's more complicated like:
global $plugin_class_var;
remove_action( 'some_hook', array($plugin_class_var, 'function_to_remove') );
Those are the basics of extending (or even 'shrinking'?) a plugin's functionality, and it's not always doable appropriately. Unfortunately the narrow answer to your question is outside of the scope of what we can provide from StackOverflow.
From here, you'll need to figure out exactly what you want to do with the plugin, and dig through the plugin's files to see if there's an appropriate hook or function you can use. If you're still stuck, you'll need to post a new question (don't update this one) with your exact desired result and anything you've tried, and the relevant code that goes along with it. "I want to change a plugin without editing core files" isn't nearly specific enough. "I want to replace an icon with a custom icon in this plugin, here's what I've tried" is specific enough to possibly answer.
Good luck!
I just went through myself and I had so many changes that I couldn't just override the actions.
I created this tool that allows you to create a child plugin like a child theme. You can make updates to the plugin and still update it without losing your changes.
I'm posting this here because it relates and hopefully becomes useful to the next person who runs into this issue.
https://github.com/ThomasDepole/wordpress-child-plugin-tool
As per WordPress standard, it's called plugin's addon.
if the plugin has provided any action to update that functionality then you can use it with your addon (child plugin).
Here I am sending a link for reference.
https://developer.wordpress.org/reference/functions/add_action/
I'm setting up my first Wordpress site. I have limited knowledge and understanding of its inner working. (Bear that in mind, please)
I setup 3 different pages that show posts based on their categories.
Though, once your reading one post, from either pages, the Next Post/Previous Post navigation still cycle thru all the posts regardless of their categorie.
I would like to limit this navigation to posts within the category of the page the reader is reading from.
Is that at all feasable and if so, can you help me out understanding how to do it?
Or if there is a plugin that does that?
Thanks
That's covered in the WP docs. Set in_same_cat to true.
https://developer.wordpress.org/reference/functions/next_post_link/
If the links are already in your theme, you'll need to edit them.
Can a post be hidden from home page, archive view, category lists etc. and viewable only if you have a direct link to it? The blog doesn't have registered readers and is open to public so that would be a mean of hiding some posts from public view without using the password protection.
I asked this question in Wordpress section and the idea there was to use conditional code so I'm asking the question here as well to get closer to the code.
If I used conditioning, would I have to input each post's ID separately to PHP file for archive, categories, search and such?
EDIT:
After reading a bit more all over, I had an idea of creating a private category and then use some kind of conditioning so that posts from that category are hidden. According to Codex, certain category can be hidden from, for example front page but I don't know if there's a way to hide it altogether except when you have a direct link.
Creating a "Private" category is a good solution. It is quite possible to hide this category altogether except via direct link. You just have to "block all the exits" with conditional code.
The default WordPress theme displays posts via the Post Loop. See http://codex.wordpress.org/The_Loop, especially the section entitled "Exclude Posts from Some Category". Just find all the places in your theme's PHP files (e.g. index.php) where this loop is used, and add the conditional code. You'd also need to filter your category list and blog archives in the side menu. Don't add filtering in single.php, otherwise the private post won't display on its own page.
You'd probably want to add a similar condition to filter search results so that private posts aren't leaked via the blog's search tool. There may be more "exits" I haven't thought of, but I'll be sure to update as I do. I'm glad to look at specific code if you so desire.
Understanding WordPress' post query and loop really opens up a world of possibilities for customization.
I found the simplest way - just use Simply Exclude Wordpress plugin. It has the option to exclude each post (or tag, for that matter) from front page, archive, search or feed. It works flawlessly. You can still view the posts by using direct links.
(Not actually an answer that includes code but a working solution nonetheless.)
I have my permalinks in WordPress set to the Month and Name setting. This generates URLs like /blog/2009/09/my-post-name. Every time a post is updated, it changes the posting date, which can potentially change the permalink address.
This is wreaking some havoc on my site, as I'll have banner/button ads throughout that point to the permalink. When a post from August is updated in September, all of the ads become broken links until I discover this and change it.
Is there any way to make the original posting date stay static, despite any updates? I'm looking for something like a plug-in or an overlooked setting, as I have multiple authors with varying degrees of computer literacy.
Thanks for any help!
Cory
Update:
Apparantly this is behaviour that others aren't experiencing, so I'm attaching a screen shot of exactly what's happening. Top image is before saving, bottom image is after saving.
(source: opl.on.ca)
Are you sure updating a post changes the permalink? I don't have this behaviour in my installations. What do changes a permalink is changing the post date.
In database, acoording to this schema, we have post__date and post__modified, two different attributes: used in create an update action. If you're having your post-date modified without modifying it directly
Updating a post date in Wordpress http://img18.imageshack.us/img18/3440/wordpresspostdate.png
then I'm afraid some plugin may be changing it's value.
Reading your description, I'm assuming you're using static links to your banners. Try to use a simple plugin that creates these links based on your post id: some simple routine would do it. You can get some information using get_post for example.
<?php
$my_id = 7;
$post_id_7 = get_post($my_id, ARRAY_A);
$slug = $post_id_7['post_name'];
?>
... or even easier with get_permalink. You need just your post id.
<?php
echo get_permalink(7);
?>
So, at least if your permalinks are changing without a reason and you dont know how to fix them, at least you can build them dinamically.
Just read the codex documentation and Function Reference to see what's avaiable to make your life easier!
I run the same permalink settings and don't have trouble with post updates changing the permalink. There are separate editor settings for the permalink and a user has to specifically change the permalink from that editor, which is right under the post title in the text editing box in the post editor. That's a WP thing to keep permalinks from getting broken all the time.
Maybe you should try using a few static pages? That way you can have both a clean permalink: mysite.com/mypermalink/ that won't change, if in fact your post permalinks are changing from a plugin that you need to use.